Thanks for the explanation. I suspected something like this but was
confused because the stack trace did not show a call to a nested
gtk_main_iteration(). I was expecting something like
com.sun.glass.ui.gtk.GtkApplication._runLoop to show up in the stack
trace again. But I guess since it is a native method, that doesn't show.
I can submit a PR to fix the OOB, but I do not have the knowledge of
whether a reentrant call like that is permitted in JavaFX. I.e. is the
actual bug the reentrant event handler or is that within the realms of
possibility in the GTK implementation and should the event handler
implementation take care of that?
This issue in general seems to be reproducible on any drag for some
users on hyprland.
On 31/05/2026 19:08, Michael Strauß wrote:
The reason for the exception is that Scene.DnDGesture.handleExitEnter
is called reentrantly.
Here's an example of what may have happened:
1. We enter handleExitEnter(), and compute j = newTargets.size() - 1
(in our example, perhaps j = 2)
2. We enter the loop and call Event.fireEvent()
3. The event handler calls GtkDnDClipboard.mimesFromSystem()
4. In the native implementation:
a. We call dnd_target_get_mimes()
b. which calls dnd_target_receive_data()
c. which calls gtk_main_iteration()
5. While we are blocked at gtk_main_iteration(), GTK processes another event
6. Let's suppose GTK is processing a drag-motion event:
a. We enter process_dnd_target_drag_motion()
b. which calls View.notifyDragOver
7. We now enter handleExitEvent() reentrantly, and complete the nested
call with:
currentTargets.clear();
currentTargets.addAll(newTargets);
newTargets.clear();
8. Eventually the outer call to Event.fireEvent() returns, and resumes
with j == 2
9. But now newTargets.size() == 0
10. newTargets.get(2) throws exactly: Index 2 out of bounds for length 0