You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to various degrees of nesting (e.g. XYPlot within a LinearLayout, within a fragment that replaces a FrameLayout of the fragment of a ViewPager2's page, ...), I've encountered a situation where the one of the dimensions of the XYPlot instance is 0, before being expended to its actual size later on.
(Apologies, I'm unable to re-create a small fully contained example.)
In this case, renderOnCanvas is called with a nullCanvas, but when we're using a background thread, isIdle is never set to true in this case (as it would with non-zero dimensions).
As a result, the background thread is stuck waiting at renderSync.wait(), and the plot can never be rendered by resizing.
Details
In a situation where rendering is done in background-thread mode, this shows these logs:
public void redraw() {
if (renderMode == RenderMode.USE_BACKGROUND_THREAD) {
// only enter synchronized block if the call is expected to block OR
// if the render thread is idle, so we know that we won't have to wait to
// obtain a lock.
if (renderThread != null && isIdle) {
synchronized (renderSync) {
renderSync.notify();
}
}
Because of that, renderSync.notify() can never be called, so the background thread is stuck at renderSync.wait(), so no further redrawing can take place.
Solution
Setting isIdle = true in Plot.renderOnCanvas seems to fix the problem:
I know you stated in the first sentence that you were unable to make a code demo of the issue, but just being perfectly honest without a demo, it could be a while before I am able to dedicate the time to investigate and fix. Alternatively you're more than welcome to open a PR if you've got a clean solution that will not negatively impact other user's use cases!
This is using Androidplot 1.5.10.
Due to various degrees of nesting (e.g. XYPlot within a LinearLayout, within a fragment that replaces a FrameLayout of the fragment of a ViewPager2's page, ...), I've encountered a situation where the one of the dimensions of the XYPlot instance is 0, before being expended to its actual size later on.
(Apologies, I'm unable to re-create a small fully contained example.)
In this case,
renderOnCanvas
is called with anull
Canvas
, but when we're using a background thread,isIdle
is never set totrue
in this case (as it would with non-zero dimensions).As a result, the background thread is stuck waiting at
renderSync.wait()
, and the plot can never be rendered by resizing.Details
In a situation where rendering is done in background-thread mode, this shows these logs:
The problem here is that the background thread, and the first pass at rendering starts with a dimension of 0 height.
In this case, the
Canvas
in thepingPong
instance isnull
, inPlot.startBackgroundrendering()
.Indeed, the
BufferedCanvas
is resized using(0,0)
, which makes itsbgBuffer
null
, and therefore makesgetCanvas()
returnnull
.As a result,
renderOnCanvas
returns straight away:The problem here, is that
isIdle
is never set to true (as it would with a non-null canvas).As a result,
redraw()
never does anything, sinceisIdle
is alwaysfalse
:Because of that,
renderSync.notify()
can never be called, so the background thread is stuck atrenderSync.wait()
, so no further redrawing can take place.Solution
Setting
isIdle = true
inPlot.renderOnCanvas
seems to fix the problem:The text was updated successfully, but these errors were encountered: