-
Notifications
You must be signed in to change notification settings - Fork 124
Description
A user reports that the Tank widget sometimes does not render at all when starting Phoebus with an OPI containing Tank widgets. Cause of this I think I have narrowed down to BufferUtil.getBufferedImage() where - if not already on JavaFX thread - the call is wrapped in Platform.runLater() and a CompletableFuture. Looks like the CompletableFuture.get() times out (default 500ms) when BufferUtil.getBufferedImage() is called initially (from a non-JavaFX thread).
BufferUtil calls AWT APIs to create objects, but why is it taken for granted that those calls must happen on the JavaFX thread? Reason I ask is that simply returning a new BufferUtil object seems to not trigger a warning related to execution on non-JavaFX thread, and also resolves the observed issue. Another change to resolve the issue is to not instantiate BufferUtil in the JavaFX-thread, but to still use a CompletanbleFuture, like so:
final CompletableFuture<BufferUtil> result = new CompletableFuture<>();
result.complete(new BufferUtil(width, height));
try
{
return result.get(500, TimeUnit.MILLISECONDS);
}
...
Am I missing something?