8198549: Desktop.setOpenURIHandler() only receives event if application is already launched - #31791
8198549: Desktop.setOpenURIHandler() only receives event if application is already launched#31791pabulaner wants to merge 2 commits into
Conversation
…on is already launched
|
👋 Welcome back pabulaner! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@pabulaner The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
…on is already launched
|
I don't see any harm in AWT sending such a message, although perhaps a CSR is needed. |
Problem description
When You create a JavaFX native application with jpackage for macOS You will run into an issue when trying to handle URIs. When Your application isn’t running and You have it registered for handling certain types of URIs it won’t receive the first URI.
Here is a simple example:
If You have a JavaFX application that handles URIs for example of the form openurifx://your-content and You have it installed with jpackage for macOS and now You try to handle an URI by running the following command:
open openurifx://hello-worldThe application will open, but it won’t receive the above URI. If You call the same command after the application is already running, everything will work fine and the application will receive the URI.
Problem cause
The cause of the problem is that when You build a JavaFX application and want to handle URIs You will have to combine JavaFX and AWT as AWT provides the URI handling capabilities. So the startup process is as follows:
The issue is that the URI event is delivered before AWT can handle it and therefore is simple dropped. That’s why later URIs will be received and are handled properly.
Fix
The fix is that JavaFX will wait until it receives a ready event from AWT so JavaFX knows that AWT is able to handle events now. After that it will forward all buffered URIs and therefore everything will be handled correctly. This means that the fix involves both the JFX and JDK repositories and needs to be integrated in both.
Note: In the case that a user has only a fix for the JFX part the URIs won’t be delivered at all, but there won’t be any error. This means that JavaFX applications won’t be able to handle any URIs so it might be an idea to add an environment variable to tell JavaFX to not wait for an AWT ready event. Then the first URI event would be lost, but at least all the following events would be handled properly.
Tests
To test the error and the fix You can clone this repository: https://github.com/pabulaner/openurifx and checkout the branch first-url. There You will find a README.md with further instructions.
PR inside JFX: openjdk/jfx#2203
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31791/head:pull/31791$ git checkout pull/31791Update a local copy of the PR:
$ git checkout pull/31791$ git pull https://git.openjdk.org/jdk.git pull/31791/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 31791View PR using the GUI difftool:
$ git pr show -t 31791Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31791.diff
Using Webrev
Link to Webrev Comment