JDK-8280383 : JavaFX Drag & Drop often hangs on Linux
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: openjfx17
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2022-01-18
  • Updated: 2022-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

Linux 4.18.0-305.19.1.el8_4.x86_64 #1 SMP Wed Sep 15 19:12:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

OpenJFX 17.0.1 

A DESCRIPTION OF THE PROBLEM :
When we try to use D&D in our application, the drag often stops working: We can still move the mouse cursor around, but the cursor is not a drag cursor anymore, the drag view (which apparently now has a default drag view enabled by default that cannot be disabled) stops moving, reactions to drag over etc. are not triggered, etc. 

We have adapted the demo code from JDK-8211302 , which reproduces the problem very reliably for us  (at least 9 out of 10 times, it happens on the first try). 
Things we have noticed:
When the bug has occurred (D&D hangs):
* It seems like no drag events occur anymore or are not properly propagated, as there are no sysouts.
* When we move the mouse cursor out of the Fx window and back in, D&D sometimes (but not always) starts working again, at least for an instant (= drag view moved to the reentry point of the mouse cursor into the window, sysouts for DRAG_OVER printed). 
* When we move the move cursor into and out of the area of where the drag view "hangs" on the screen, there are some reactions (drag view moves a bit, sysouts for DRAG_OVER printed)
* When we move the mouse cursor out of the window (easiest at the top) and quickly onto the green area that is the possible drop target, D&D starts/keeps working (correct drag cursor, drag view moves around, expected sysouts printed, dropping works, etc.). 

We can provide a video of the bug occurring if desired.

We assume that the problem has something to do with the drag view for two reasons:
First, D&D starts working for a short amount of time when we move the mouse over the are of the hanging drag view.
Secondly, we already had similar problems using D&D with OpenJFX 13.0.1 and using a custom drag view. With that version, we could just NOT set the custom drag view, and D&D then worked reliably. OpenJFX 17 however has a default drag view that is displayed when no custom drag view is set, and we cannot work around the issue anymore.
Under Windows 10, we could not reproduce the problem. When no drag view is explicitly specified, there IS no drag view ( = no default drag view), and D&D works as expected.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test program. 
Drag the source label (yellow/left) around for a bit. Maybe several tries are needed until the bug occurs.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Drag cursor should be moved, default drag view should follow the mouse cursor. Sysouts for drag events should be printed. Mouse cursor should change when over the drop target (green label/right).
ACTUAL -
When the bug occurs, the mouse cursor becomes the default cursor instead of the drag cursor, the default drag view stops moving (= "hangs" somewhere on the screen), and there are no more sysouts for drag events. The mouse cursor does not change when over the drop target (green label/right).

---------- BEGIN SOURCE ----------
public static class DndDemoApp extends Application {

        @Override
        public void start(Stage stage) {
            HBox root = new HBox();
            root.setPadding(new Insets(5));
            root.setSpacing(25);

            Scene scene = new Scene(root, 400, 200);

            final Label source = new Label("DRAG ME");
            source.setCursor(Cursor.HAND);
            source.setBackground(new Background(new BackgroundFill(Color.YELLOW, CornerRadii.EMPTY, Insets.EMPTY)));

            final Label target = new Label("DROP HERE");
            target.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, Insets.EMPTY)));

            root.addEventHandler(DragEvent.ANY, evt -> {
                System.out.println("drag event: " + evt.getEventType());
            });

            source.setOnDragDetected((event) -> {
                System.out.println("onDragDetected");

                Dragboard db = source.startDragAndDrop(TransferMode.MOVE);
                ClipboardContent content = new ClipboardContent();
                content.putString("DRAGGED CONTENT");
                db.setContent(content);

                // not setting drag view made D&D work reliably with JFX 11, but under JFX 18 it's broken anyway    
                // db.setDragView(...);

                event.consume();
            });

            source.setOnDragDone((event) -> {
                System.out.println("onDragDone");

                event.consume();
            });

            target.setOnDragOver((event) -> {
                System.out.println("onDragOver");

                if (event.getGestureSource() != target && event.getDragboard().hasString()) {
                    event.acceptTransferModes(TransferMode.MOVE);
                }

                event.consume();
            });

            target.setOnDragEntered((event) -> {
                System.out.println("onDragEntered");

                event.consume();
            });

            target.setOnDragExited((event) -> {
                System.out.println("onDragExited");

                event.consume();
            });

            target.setOnDragDropped((event) -> {
                System.out.println("onDragDropped");

                Dragboard db = event.getDragboard();
                boolean hasString = db.hasString();
                if (hasString) target.setText(db.getString());

                event.setDropCompleted(hasString);

                event.consume();
            });

            root.getChildren().add(source);
            root.getChildren().add(target);
            stage.setScene(scene);
            stage.show();
        }

        public static void main(String[] args) {
            Application.launch(args);
        }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None found.

FREQUENCY : always



Comments
Additional Information from submitter: =========================== Video of behavior with OpenJFX 13.0.1 (works fine): <jfx13.mp4> Video of buggy behavior with OpenJFX 17.0.2 (broken): <jfx17.mp4> This one shows four dragging operations, all of which are buggy/broken: * one drag from 0:01 to 0:38 * one drag from 0:39 - 0:52 * one drag from 0:52 - 0:54 * one drag from 0:52 - end The clipping were created when we were using: • gtk3.x86_64 3.22.30-6.el8 • openjdk version "11.0.13" 2021-10-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing) • Linux 4.18.0-305.19.1.el8_4.x86_64 #1 SMP Wed Sep 15 19:12:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux We can always reproduce the problem with this combination. --- We can also "partially" reproduce the problem with the following combination: • gtk3.x86_64 3.22.30-6.el7 • openjdk version "11.0.12" 2021-07-20 LTS OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing) • Linux 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux • OpenJFX 17.0.2 With this combination, we also sometimes see hanging (but most of the time it works fine). If the hanging occurs, moving the cursor out of the Fx window and back inside usually fixes it. --- We could NOT reproduce the problem with the following combination: • libgtk-3-0/stable,now 3.24.24-4 • OpenJDK 64-Bit Server VM (build 11.0.13+8-post-Debian-1deb11u1, mixed mode, sharing) • Debian 11.2 • OpenJFX 17.0.1 fx
31-01-2022

Checked with attached testcase in Ubuntu 20.04, gtk version : 3.4.20, Issue is not reproducible, (hang was not observed, Mouse cursor change observed when over the drop target (green label/right). Test Result: ======== openjfx11: Pass openjfx17: Pass openjfx18ea: Pass Mail to Submitter: ============= Please share the GTK Version? And also share the short clipping of the issue.
20-01-2022