Headless glass platform
Johan Vos
johan.vos at gluonhq.com
Wed Apr 10 11:45:08 UTC 2024
Hi Craig,
Thanks for testing and for the feedback. Based on that feedback, I pushed a
change so that the HeadlessApplication now responds properly to a
`Platform.exit()` call (see
https://github.com/openjdk/jfx-sandbox/commit/5c8bcb2ca1f7a72f34c3e53e209b818abf8f8504
).
My implementation does a gentle stop of the processing thread, and already
submitted runnables will be handled before the processing halts. I think
this is how it should be, and it works with a simple application, but I
didn't test it with a jpackaged application yet. It would be great if you
can confirm that this is now fixed?
Thanks again for the feedback!
- Johan
On Tue, Apr 9, 2024 at 11:37 AM Craig Raw <craigraw at gmail.com> wrote:
> Hi Johan,
>
> As you advised in another thread, I've tested the headless glass platform
> and find it to be an excellent solution. My particular use case is to
> provide an alternative terminal interface (using Lanterna) for a JavaFX
> application without needing to rewrite a great deal of the logic. For this
> purpose, the headless glass platform works very well as a replacement to
> Monocle.
>
> I encountered only one problem - calling Platform.exit() did not terminate
> the application after it had been packaged with jpackage. This did not
> occur with the same code using the JavaFX18 Monocle libraries on Linux
> amd64. The JavaFX application thread was the only non-daemon thread at this
> point. I solved this fairly simply by calling System.exit(0) after
> Platform.exit().
>
> As an aside, I was impressed by how simple it was to build JavaFX. I was
> surprised though that javafx.graphics.jar did not contain the native
> libraries, and I had to repackage the jar to include them manually. There
> are probably good reasons for this, but it wasn't obvious.
>
> It would be really good to see the headless glass platform merged into
> JavaFX proper, and would allow me to move beyond JavaFX 18, the last
> version to have Monocle support for Linux amd64.
>
> Craig
>
> On Fri, Feb 2, 2024 at 10:50 AM Marius Hanl <mariushanl at web.de> wrote:
>
>> I agree that this a nice feature, especially for headless tests as you
>> also mentioned.
>> Really looking forward to this feature.
>>
>> - Marius
>>
>> *Gesendet:* Dienstag, 30. Januar 2024 um 12:46 Uhr
>> *Von:* "Johan Vos" <johan.vos at gluonhq.com>
>> *An:* "openjfx-dev" <openjfx-dev at openjdk.org>
>> *Betreff:* Headless glass platform
>> Hi,
>>
>> I created a branch in the jfx-sandbox repository for experimenting with a
>> headless glass platform:
>> https://github.com/openjdk/jfx-sandbox/tree/johanvos-headless
>>
>> This addresses https://bugs.openjdk.org/browse/JDK-8324941 where I
>> suggest a POC for a Headless platform.
>>
>> There are a number of usecases for this, including:
>> 1. applications that require JavaFX rendering without presenting this to
>> a window (and instead send it to a printer for example)
>> 2. running tests without requiring a window manager.
>>
>> Regarding the second usecase, we already did some basic experiments using
>> a modified version of TestFX where instead of the Monocle Headless
>> subplatform, the POC Headless platform is used.
>>
>> By using a first-class Headless glass platform instead of a Monocle
>> subplatform, it should be easier to use by developers.
>> The monocle code contains very platform/os specific parts, which often
>> don't make sense outside the target platform. This is very valuable, but it
>> is also a very different usecase than a headless platform and it requires a
>> much more complex build procedure.
>>
>> I added an initial, limited HeadlessRobot to do some basic tests. That
>> code is mainly taken from the existing Monocle implementation, but I want
>> to be careful to avoid anything that is not applicable to the headless
>> scenarios.
>>
>> - Johan
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240410/477c6f1d/attachment.htm>
More information about the openjfx-dev
mailing list