On Mon, 18 Dec 2023 at 09:57, Michael Berry <
berr...@gmail.com> wrote:
> While my post was being approved I've made some more progress - the issue is to do with the sample being disposed in FXSink while it's still being used. I'm still entirely not quite clear *why* it's being used after being disposed, but simply keeping the last 2 samples around seems to make this, and all other cases I could find rock solid (the following hacked FXImageSink is the one I'm now using:
https://github.com/quelea-projection/Quelea/blob/master/Quelea/src/main/java/org/quelea/windows/video/FXImageSink.java). I can only think JFX is doing some kind of buffering that still requires the last few frames to be kept - but this is a complete guess.
>
> Happy to raise a PR, but wasn't going to jump to do that given I'm still not entirely certain on what's going on!
Yes, sorry, this is a known issue with FXImageSink. Actually, it's a
known issue with threading in the JavaFX API - see
https://mail.openjdk.org/pipermail/openjfx-dev/2020-February/025103.html
The FXImageSink was originally written as a proof of concept for a
client project, although that project involved me writing them a
completely bespoke binding without gst1-java-core or gst1-java-fx.
The fix applied in that code was to release the sample within a
Platform::runLater as mentioned in that openjfx-dev thread. That
always worked in practice, although unfortunately the JavaFX
PixelBuffer API and threading model is flawed, and lacking the rather
important ability to inform the application code when it's done with
native memory.
I'll see if I can find the fix I used in the client's code and compare
with what you've shared.
Best wishes,
Neil
--
Neil C Smith
Codelerity Ltd.
www.codelerity.com
Codelerity Ltd. is a company registered in England and Wales
Registered company number : 12063669
Registered office address : 3rd Floor Suite, 207 Regent Street,
London, W1B 3HH, England