OneZoom / OZtree

OneZoom Tree of Life Explorer
Other
91 stars 20 forks source link

Site can get into a mode where the UI doesn't refresh properly #922

Open davidebbo opened 4 days ago

davidebbo commented 4 days ago

@jaredkhan this is new to the high res change. I don't have a consistent repro, but I've now seen it 3 times. It happens in the morning after I wake my machine up and connects it back to my main monitor. This is on Windows 11 / Chrome.

It ends up in a state where things don't properly refresh outside of a smaller rectangle as I pan around or zoom in/out, e.g.

image

Resizing the window fixes it. I think it somehow misses a resolution change event, and still acts as if it's on my smaller laptop screen, instead of the high res big screen. However, if it's in a good state and I simply move the window from the small to the big screen, it doesn't happen (in fact, I see it 'flash' as it redraws).

It's not a huge deal all things considered, as it happens rarely and is easy to fix, but there is a refresh bug somewhere.

jaredkhan commented 3 days ago

Yeah, that's not great! The screenshot is helpful.

Is that the whole window you've screenshotted or just a portion of it?

It's interesting too that the screenshot shows a branch with no leaf at the end of it, suggesting that we're seeing something that the renderer doesn't think we can see. It's all consistent with the scale on the context not being set. If I comment out the line that sets the scale I get this:

image

but I can't see any obvious reason that the canvas width would be changed without the scale getting set. Will have a bit more of a look though.

jaredkhan commented 3 days ago

Theory so far, since you mentioned waking from sleep, is that the canvas context is lost and reset in a way that we're not detecting, since there's no resize going on, so the scale is set back to 1 without us seeing any event that would cause us to set the scale.

Perhaps a sensible fix would be to store the scale factor in the renderer, and then reset the transform and set the scale on each frame, which is cheap relative to what we used to do before this set of changes.

jaredkhan commented 3 days ago

Fix would be something like this if so: https://github.com/OneZoom/OZtree/pull/923

davidebbo commented 3 days ago

Is that the whole window you've screenshotted or just a portion of it?

It was a portion.

This is on the main branch?

Saw it both on https://www.onezoom.org/extinct/life/, which has main, and on my own server, which had another change of yours I was testing.

Have you seen it on the extant tree at all? I'm not exactly clear how the extinct page is setup. Perhaps @hyanwong can explain how it works? I imagine it's not that, just checking that this is using the exact same code.

No, the extant tree has not been updated with your changes yet. I only saw it on the extinct tree.

I have pulled #923, so I'll see what happens after a while running. Thanks!

jaredkhan commented 3 days ago

Thanks @davidebbo!