Thanks for your quick reply, Erel.
No, the error does not crash the app right away, but once the error has occurred all subsequent calls to Canvas.Shapshot throw the same error, as described in the JDK Bug Report:
“After this moment, every GUI rendering causes a NullPointerException (triggered by the method BaseContext.flushMask()), meaning an endless loop causing a GUI freeze.”
After 129 times, the app crashes.
Finding exactly what triggers the error is not easy. The Canvas.Shapshot statement is inside nested loops and is executed very frequently. Sometimes it throws the error almost immediately, at other times only after hundreds of thousands of calls. It does not seem to depend on the canvas size nor the number of vertices in the clipping polygon applied to the canvas using ClipPath. My code does trap the error when it occurs but is unable to resume its calculations because Canvas.Shapshot has stopped working.
As a temporary patch, I have implemented a monitor app which runs as an independent process. When the main app traps the error it raises a flag (in a file) before terminating. The monitor app detects the flag and restarts the main app which continues its calculations where it left off. This works but is not a satisfactory long term solution.
I have also tried or considered the following:
1) Allocating additional memory using -Xmx10G
It does not help.
Would using -Dprism.maxvram=10G be more effective?
But this is still not a satisfactory long term solution, crashes would eventually occur when processing large datasets.
2) Forcing garbage collection at regular intervals as outlined here
Hello For those of you interested in GC here is a class I have in a B4J server: Sub Class_Globals Private tmrHook As Timer Private gcTime As Long Private freq_gc As Int = 1 End Sub Public Sub Initialize ' // 3 seconds...
www.b4x.com
It does not help.
Is there a way to force the specific cleanup referred to in the JDK Bug Report?
“If the BaseResourcePool runs out of available space (maxSize is reached), it performs
a cleanup to remove dead/unused textures and free some space.”
3) Do you think that switching from Open JDK 11 to Oracle Java 8 might help?
Any other ideas?
Thanks.