Skip to content

Timeout in BufferUtil #3751

@georgweiss

Description

@georgweiss

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions