On Mon, 9 Jun 2025 22:09:44 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

> > > I'd looked at that but it was not obvious. And it definitely is not 
> > > obvious that it will be the same thread that initialises the 
> > > MaskMarlinAlphaConsumer.java class
> > 
> > Yes, I see what you are saying. The `ALPHA_MASK_XXX` arrays are static 
> > fields of `MaskMarlinAlphaConsumer`, and the renderer context class has an 
> > instance field of `MaskMarlinAlphaConsumer`. So it does seem possible that 
> > `MaskMarlinAlphaConsumer` could be initialized by a thread other than the 
> > prism renderer thread. Hmmm.
> 
> Fortunately, the presence of following field in RendererConext does not cause 
> the MaskMarlinAlphaConsumer class to be initialized:
> 
> ```
>     public MaskMarlinAlphaConsumer consumer = null;
> ```
> 
> I instrumented the code, adding something that _did_ force initialization and 
> was able to provoke a WrongThreadException. Without my modification, 
> MaskMarlinAlphaConsumer doesn't get initialized until rendering.
> 
> This seems _very_ fragile, though. At best, presuming we can prove that 
> initialization and access to MaskMarlinAlphaConsumer always happens on the 
> Prism rendering thread, this is an accident waiting to happen.
> 
> @bourgesl Do you have any thoughts on this? Using the shared arena is 
> definitely safer, but there might be a performance penalty.

These alpha masks are constant (static), so reused in marlin java2d where 
multiple threads & rendering contexts can work in parallel.
With FFM, the global arena could be used, but the current patch is good enough 
as javafx uses only 1 thread to perform rendering.
I hope using the shared arena does not hurt performance in this case (1 thread).

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2959886137

Reply via email to