From eb3d0d25d07738b42a8d7aae334a01fe65c9e6dd Mon Sep 17 00:00:00 2001 From: georgweiss Date: Fri, 27 Mar 2026 08:44:41 +0100 Subject: [PATCH 1/2] Retry image buffer instantiation on timeout --- .../org/csstudio/javafx/rtplot/RTTank.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java index 365d0ab5be..e7b9d4a81f 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java @@ -68,6 +68,8 @@ public class RTTank extends Canvas /** Is the scale displayed or not. */ private volatile boolean scale_visible = true; + protected final AtomicBoolean needUpdate = new AtomicBoolean(true); + /** Listener to {@link PlotPart}s, triggering refresh of canvas */ protected final PlotPartListener plot_part_listener = new PlotPartListener() { @@ -120,11 +122,19 @@ public RTTank() // 50Hz default throttle update_throttle = new UpdateThrottle(50, TimeUnit.MILLISECONDS, () -> { - plot_image = updateImageBuffer(); - redrawSafely(); + if (needUpdate.getAndSet(false)){ + plot_image = updateImageBuffer(); + if(plot_image != null){ + redrawSafely(); + } + else{ + requestUpdate(); + } + } }); } + /** Update the dormant time between updates * @param dormant_time How long throttle remains dormant after a trigger * @param unit Units for the dormant period @@ -196,8 +206,8 @@ public void setLogScale(final boolean logscale) } /** Set value range - * @param low - * @param high + * @param low Lower limit + * @param high Upper limit */ public void setRange(final double low, final double high) { @@ -243,7 +253,7 @@ protected Image updateImageBuffer() if (buffer == null) return null; final BufferedImage image = buffer.getImage(); - final Graphics2D gc = buffer.getGraphics(); + final Graphics2D gc = image.createGraphics(); gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gc.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED); @@ -306,6 +316,7 @@ else if (scale.isLogarithmic()) // by mellguth2, https://github.com/ControlSyste /** Request a complete redraw of the plot */ final public void requestUpdate() { + needUpdate.set(true); update_throttle.trigger(); } From 7e2a3fb8bc721c57ba17c07523c4e74c7a626e1f Mon Sep 17 00:00:00 2001 From: georgweiss Date: Fri, 27 Mar 2026 09:02:58 +0100 Subject: [PATCH 2/2] Roll back accidental change --- .../src/main/java/org/csstudio/javafx/rtplot/RTTank.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java index e7b9d4a81f..ddb81de2e8 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java @@ -119,11 +119,11 @@ public RTTank() widthProperty().addListener(resize_listener); heightProperty().addListener(resize_listener); - // 50Hz default throttle + // 20Hz default throttle update_throttle = new UpdateThrottle(50, TimeUnit.MILLISECONDS, () -> { if (needUpdate.getAndSet(false)){ - plot_image = updateImageBuffer(); + plot_image = updateImageBuffer(); // This will return null if image buffer instantiation times out if(plot_image != null){ redrawSafely(); } @@ -253,7 +253,7 @@ protected Image updateImageBuffer() if (buffer == null) return null; final BufferedImage image = buffer.getImage(); - final Graphics2D gc = image.createGraphics(); + final Graphics2D gc = buffer.getGraphics(); gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gc.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);