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

backport-2.0: ui: Fix Zoom Bug on Cluster Map #24183

Merged
merged 1 commit into from
Mar 26, 2018

Conversation

mrtracy
Copy link
Contributor

@mrtracy mrtracy commented Mar 23, 2018

Backport 1/1 commits from #24164.

/cc @cockroachdb/release


Fixes a bug where zoom behavior could become broken after zooming all
the way out on the cluster map.

This happened because the react-land state (ZoomTransformer) got out of
sync with the d3 zoom state whenever we applied an adjustment in the
ZoomTransformer - we were not informing the d3 zoom behavior of the
change, and thus the zoom behavior thought we were at a different zoom
level than was actually displayed, causing the zoom to behave
unpredictably. This is fixed by synchronizing the zoom state back to d3
in the OnZoom event.

However, this exposes another bug where animations are broken; with the
synchronization fix applied, freely panning and zooming would cause the
next animation to have the wrong start position - the animation would
begin from wherever the last programmatic animation stopped. After
reading some source code, it turns out that this is a mutation curiosity
in d3. Zoom.event maintains an object with the current translation and
scale which it shares with the zoom behavior. Oddly, free pan-and-zoom
events directly mutate this object, while calling .scale() or
.translate() cause a copy-on-write situation. This means that setting
the zoom or translation programmatically without going through
zoom.event will cause this animation bug.

Fixes #24160

Release note (Admin UI): Fixed a bug where zooming on the node map could
break after zooming out to the maximum extent.

Fixes a bug where zoom behavior could become broken after zooming all
the way out on the cluster map.

This happened because the react-land state (ZoomTransformer) got out of
sync with the d3 zoom state whenever we applied an adjustment in the
ZoomTransformer - we were not informing the d3 zoom behavior of the
change, and thus the zoom behavior thought we were at a different zoom
level than was actually displayed, causing the zoom to behave
unpredictably.  This is fixed by synchronizing the zoom state back to d3
in the OnZoom event.

However, this exposes another bug where animations are broken; with the
synchronization fix applied, freely panning and zooming would cause the
next animation to have the wrong start position - the animation would
begin from wherever the last programmatic animation stopped. After
reading some source code, it turns out that this is a mutation curiosity
in d3. Zoom.event maintains an object with the current translation and
scale which it shares with the zoom behavior.  Oddly, free pan-and-zoom
events directly mutate this object, while calling `.scale()` or
`.translate()` cause a copy-on-write situation. This means that setting
the zoom or translation programmatically without going through
zoom.event will cause this animation bug.

Fixes cockroachdb#24160

Release note (Admin UI): Fixed a bug where zooming on the node map could
break after zooming out to the maximum extent.
@mrtracy mrtracy requested review from couchand and a team March 23, 2018 17:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mrtracy mrtracy merged commit 9681aa4 into cockroachdb:release-2.0 Mar 26, 2018
@mrtracy mrtracy deleted the backport2.0-24164 branch March 26, 2018 17:31
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.

3 participants