Bug 1961119 - Java Desktop.getDesktop( ).browse( URI ) regression in Fedora 34
Summary: Java Desktop.getDesktop( ).browse( URI ) regression in Fedora 34
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: java-latest-openjdk
Version: 35
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Mario Torre
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1965832 1966176 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-17 09:57 UTC by Ralf Folkerts
Modified: 2022-12-13 15:23 UTC (History)
13 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-12-13 15:23:22 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Test that Executes the Desktop... outside of AET (538 bytes, text/plain)
2021-05-17 09:57 UTC, Ralf Folkerts
no flags Details
Test that executes Desktop... from within AET (957 bytes, text/plain)
2021-05-17 09:58 UTC, Ralf Folkerts
no flags Details
C based test (379 bytes, text/x-csrc)
2021-09-24 19:33 UTC, Robert Marcano
no flags Details
Updated test (1.18 KB, text/plain)
2021-10-18 18:42 UTC, Robert Marcano
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNOME Gitlab GNOME gtk issues 4278 0 None None None 2021-09-24 20:15:55 UTC
openjdk bug system JDK-8275494 0 None None None 2021-10-19 10:37:26 UTC

Description Ralf Folkerts 2021-05-17 09:57:07 UTC
Created attachment 1784005 [details]
Test that Executes the Desktop... outside of AET

Description of problem:

Java Desktop.getDesktop( ).browse( URI ) only goes to the Browser after an Application exits.

This did work with Fedora 33, started after Upgrade to 34.

I tried Java 1.8.0 openjdk, Java 11 openjdk and Oracle Java 1.8.0_202, the behavious is always the same.

I stepped into it until classloader.findNative, where it finds /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-0.fc34.x86_64/jre/lib/amd64/libawt_xawt.so
and calls Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show.

Version-Release number of selected component (if applicable):

Fedora 34 (Workstation Edition)
java-1.8.0-openjdk-devel-1.8.0.292.b10-0.fc34.x86_64
java-11-openjdk-devel-11.0.11.0.9-0.fc34.x86_64


How reproducible:

Call Desktop.getDesktop( ).browse( URI ) from a Java Program.

Steps to Reproduce:
1. Compile attached Java Source 
1.1 one runs the Desktop.getDestop in AET, the other outsise of AET
1.1.1 just see I can only add one Attachment; will try to add the second test after Submission
2. Run

Actual results:

The Browser opens after the Program terminates

Expected results:

The Browser should open while the Program is still running

Additional info:

Comment 1 Ralf Folkerts 2021-05-17 09:58:35 UTC
Created attachment 1784006 [details]
Test that executes Desktop... from within AET

Comment 2 Ralf Folkerts 2021-05-17 10:05:57 UTC
Forgot to mention :( I'm using the Gnome Desktop and tried with Xorg and Wayland. I recognized the Problem when using an Application that uses the KeycloakInstalled-Adapter loginDesktop which stopped working after Updating from Fedora 33 to 34.

Comment 3 jiri vanek 2021-05-17 10:06:41 UTC
It sounds more like gnome 40 issue.

Comment 4 Severin Gehwolf 2021-05-31 15:52:09 UTC
*** Bug 1966176 has been marked as a duplicate of this bug. ***

Comment 5 Severin Gehwolf 2021-05-31 15:54:57 UTC
*** Bug 1965832 has been marked as a duplicate of this bug. ***

Comment 6 Robert Marcano 2021-09-24 15:37:52 UTC
Adding more details in case someone takes this critical bug. The Desktop.open() call hangs too, but only in some conditions. If the associated application is gedit or GNOME Builder, for example a .txt or .sql file, the application open immediately. In the case of Evince (.pdf) or LibreOffice (.ods) the call hangs and the document is opened at the end of the Java process.

Java 11 presents the problem too. It could be a GNOME bug or an improper use of GNOME APIs by Java that wasn't triggered before GNOME 40.

Comment 7 Robert Marcano 2021-09-24 19:32:56 UTC
Confirmed as a non Java bug. Build next attachment with:

gcc -Wno-deprecated-declarations `pkg-config --cflags gtk+-3.0` -o example example.c `pkg-config --libs gtk+-3.0`.

Invoke as

./example file:///...path_to.pdf

The example replicate the steps Java does at https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c#L84

Commenting the gdk_threads_enter() and gdk_threads_leave() doesn't change anything.

Comment 8 Robert Marcano 2021-09-24 19:33:46 UTC
Created attachment 1826030 [details]
C based test

Comment 9 Robert Marcano 2021-09-24 20:15:55 UTC
Reported at upstream GTK at https://gitlab.gnome.org/GNOME/gtk/-/issues/4278

Comment 10 Robert Marcano 2021-10-18 18:41:03 UTC
Upstream GTK issue reports that a GTK main loop is needed and my C based test was updated to add it and then gtk_show_uri started to work.

For what I see in OpenJDK codebase, doesn't have a permanent GTK main loop. It start one on demand when needed, for example when opening a native GTK FileDialog [1]

The next example attachment shows the problem from the Java side. If Test is invoked with one argument, being it the PDF file URI  like file:///path_to_pdf.pdf, the process must end after the final 10 seconds timeout for the PDF to open, but if it is invoked with two arguments like:

 --dialog  file:///path_to_pdf.pdf

The PDF is opened immediately, because a FileDialog instance is opened concurrently and that means a GTK main loop is running. 


[1] https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c#L418

Comment 11 Robert Marcano 2021-10-18 18:42:35 UTC
Created attachment 1834393 [details]
Updated test

Comment 12 Severin Gehwolf 2021-10-19 10:35:47 UTC
Thanks for this, Robert! I've reported it upstream to OpenJDK as:
https://bugs.openjdk.java.net/browse/JDK-8275494

Comment 13 Robert Marcano 2022-01-21 12:36:26 UTC
Since the OpenJDK bug isn't open to everyone I want to add this:

There are other alternative solutions that may not involve loading a native library. The most simple of them is to invoke the standard /usr/bin/xdg-open command.

Another option is to implement the XDG Shared MIME-info Database specification, but that is more code to maintain and could have other implications, like opened applications inheriting the current application environment, something that doesn't happen when using xdg-open, at least on a GNOME session.

Comment 14 Ben Cotton 2022-05-12 16:17:07 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 15 Ben Cotton 2022-11-29 16:57:22 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 16 Ben Cotton 2022-12-13 15:23:22 UTC
Fedora Linux 35 entered end-of-life (EOL) status on 2022-12-13.

Fedora Linux 35 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.