Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand fixed resolution buffer beyond the image boundaries to make panning seamless #246

Merged
merged 7 commits into from
Sep 14, 2021

Conversation

astrofrog
Copy link
Member

I think this will resolve spacetelescope/jdaviz#564

@pllim
Copy link
Contributor

pllim commented Aug 3, 2021

Does this go with another fix that disable actual pan until mouse button is up? Or this is it?

@codecov
Copy link

codecov bot commented Aug 3, 2021

Codecov Report

Merging #246 (8fde165) into main (22f46da) will decrease coverage by 0.43%.
The diff coverage is 36.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
- Coverage   89.11%   88.68%   -0.44%     
==========================================
  Files          82       82              
  Lines        4044     4074      +30     
==========================================
+ Hits         3604     3613       +9     
- Misses        440      461      +21     
Impacted Files Coverage Δ
glue_jupyter/bqplot/common/tools.py 70.43% <25.00%> (-2.09%) ⬇️
glue_jupyter/bqplot/image/frb_mark.py 52.63% <25.00%> (-10.79%) ⬇️
glue_jupyter/bqplot/image/state.py 100.00% <100.00%> (ø)
glue_jupyter/bqplot/image/viewer.py 87.30% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22f46da...8fde165. Read the comment docs.

@astrofrog
Copy link
Member Author

I will do a separate PR for the mouse button fix, but you can already try this PR out as it will give you the biggest benefit

@@ -56,6 +56,12 @@ def update(self, *args, **kwargs):
ymin = self.viewer.figure.axes[1].scale.min
ymax = self.viewer.figure.axes[1].scale.max

# Expand beyond the boundary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean when the whole image already fits in the view? Does it do unnecessary computation in that case, or is this smart enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is smart enough :)

@pllim
Copy link
Contributor

pllim commented Aug 3, 2021

With glue-jupyter 0.7:

Screenshot 2021-08-03 132233

With this patch (more performant but display looks grainier):

Screenshot 2021-08-03 131857

@rosteen
Copy link
Contributor

rosteen commented Aug 3, 2021

Agreed with @pllim - the performance is vastly better, but the display scaling seems strangely different (and I don't see why the small code change here would have affected that). See the two short movies below for an example of what I'm talking about. With this PR, there are a bunch of bright pixels that seem to change location when panning, which is quite annoying.

Screen.Recording.2021-08-03.at.2.46.35.PM.mov
Screen.Recording.2021-08-03.at.2.55.09.PM.mov

@pllim
Copy link
Contributor

pllim commented Aug 3, 2021

Maybe the ny and nx need updating too:

bounds = [(ymin, ymax, ny), (xmin, xmax, nx)]

Min/max changed but ny and nx remained as before, which would explain the degraded resolution.

@pllim
Copy link
Contributor

pllim commented Aug 3, 2021

I dunno, maybe something like this? With this, resolution improved and still appeared somewhat performance on drag/zoom, but I did notice a lag in loading (or has it been always there?). 🤷

--- a/glue_jupyter/bqplot/image/frb_mark.py
+++ b/glue_jupyter/bqplot/image/frb_mark.py
@@ -65,7 +65,8 @@ class FRBImage(ImageGL):
         if xmin is None or xmax is None or ymin is None or ymax is None:
             return

-        ny, nx = self.shape
+        ny = self.shape[0] + int(dy * 0.5)
+        nx = self.shape[1] + int(dx * 0.5)

         # Set up bounds
         bounds = [(ymin, ymax, ny), (xmin, xmax, nx)]

p.s. I also attempted the "only update pan on dragend" but didn't get anywhere. I went as far as setting PanZoom(..., allow_pan=False) and tried to handle the pan manually but didn't work. I'll leave it to the experts...

@astrofrog
Copy link
Member Author

@rosteen @pllim - oops good catch about the resolution, should be fixed now. Let me know what the performance is like.

@rosteen
Copy link
Contributor

rosteen commented Aug 4, 2021

Looks like that resolved the problem I was seeing. The resolution looks good now, and the performance is much better than it was. I still get some white space that takes a moment to fill in occasionally when zoomed in and panning, but it is way better than the constant slow drawing previously.

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolution seems fine now. As @rosteen said, there is still some lag if you pan around or zoom too much real fast, but some improvement is better than no improvement.

@pllim
Copy link
Contributor

pllim commented Aug 4, 2021

Hold on... Toolbar is laggy when I re-enable linking in the Imviz example notebook with this patch. Do you also see the same problem?

@pllim
Copy link
Contributor

pllim commented Aug 4, 2021

Especially the blinking. Blink is now laggy.

@astrofrog
Copy link
Member Author

Yes that could well be - the issue is that the image will now take longer to generate, so blinking could end up being a bit slower. I need to think a little more about how we can improve performance across the board.

@astrofrog
Copy link
Member Author

The issue is that this currently slows down the main display of the image, so it would be better to asynchronously load the image outside the field of view after the main visible image has been updated.

@pllim
Copy link
Contributor

pllim commented Aug 10, 2021

Re: #246 (comment) -- Does that mean you plan to push more commit to this before I review, or is that "future work"? (Tom said this PR is no-go.)

@astrofrog
Copy link
Member Author

I've now made this effectively opt-in for now until we come up with a more elegant solution. To opt in to this, downstream packages should set the viewer.state.image_external_padding property - for instance, to expand the image by 50% in all directions, this value should be set to 0.5.

@pllim
Copy link
Contributor

pllim commented Sep 14, 2021

Thanks, but this isn't really usable for MVP unless you plan to release it in the next 2 days.

@astrofrog
Copy link
Member Author

Watch me 😆

@astrofrog astrofrog merged commit d57fc92 into glue-viz:main Sep 14, 2021
@astrofrog
Copy link
Member Author

See spacetelescope/jdaviz#864 for using this in jdaviz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Imviz pan/zoom needs improvements (lag in pan)
3 participants