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

minimize scale changes when panning in globe view #11951

Merged
merged 15 commits into from
Jun 7, 2022
Merged

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Jun 1, 2022

Attempts to fix #11353 and partially mitigate #11811

The underlying problem is that the zoom is a muddy concept used for all of:

  • rendering scale (camera zoom)
  • level-of-detail data loading (tile zoom)
  • styling (style zoom)

Globe view diverges from mercator on rendering scale inherently but we're still using mercator tiles and styles designed with mercator zoom levels. This leads to conflicting requirements.

This solution compromises. It tries to:

  • keep rendering scale exactly the same as mercator at z >= 5
  • keep rendering scale roughly similar to mercator at z < 5
  • avoid zoom level changes when panning
  • avoid (minimize) rendering scale changes when panning
  • keep tile zoom levels as close to the current zoom levels for as many tiles as possible
  • keep the number of tiles as low as possible (conflicts with previous bullet point)

This tries to find a compromise between all these conflicting goals. The real solution here is to introduce a new scale concept and support that properly. In the mean time, this should be better than what we currently have.

TODO full description

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

@ansis ansis requested a review from karimnaaji June 1, 2022 23:04
@karimnaaji karimnaaji requested a review from mpulkki-mapbox June 2, 2022 00:11
@mpulkki-mapbox
Copy link
Contributor

This looks great! One bug I noticed is that the camera starts jumping if the terrain has been enabled. This is caused by transform.recenterOnTerrain which should be disabled if the globe view is active. (Btw that function is also a good candidate for future refactoring :) ).

@mpulkki-mapbox
Copy link
Contributor

I also noticed an existing "bug" that is more visible now that the reference scale is higher than previously. Draped lines are more blurred around ~1.99 zoom level when approaching from a lower zoom level (e.g. zooming from 0 to 1.99) compared to zooming out (e.g. zooming out from 3 to 1.99).

After a quick investigation I believe this is caused by the function getPixelsToTileUnitsMatrix using transform.zoom for computing the scale which shouldn't be done in draped rendering. While draping the zoom value is either ~1 or ~1.99 depending on direction of the zoom leading to this kind of blurriness. Fixed tile zoom level should be used instead. cc @karimnaaji.

globe_pan_magnification.mp4

src/geo/transform.js Outdated Show resolved Hide resolved
src/geo/transform.js Outdated Show resolved Hide resolved
src/geo/transform.js Outdated Show resolved Hide resolved
@SnailBones SnailBones added the skip changelog Used for PRs that do not need a changelog entry label Jun 2, 2022
@SnailBones
Copy link
Contributor

I'm noticing that around level 4, #11353 is still quite visible. Should we consider continuing this behavior past zoom level 5 or is this outweighed by the issues with styling and tile loading?

zoomies.mov

@SnailBones
Copy link
Contributor

I also noticed an existing "bug" that is more visible now that the reference scale is higher than previously. Draped lines are more blurred around ~1.99 zoom level when approaching from a lower zoom level (e.g. zooming from 0 to 1.99) compared to zooming out (e.g. zooming out from 3 to 1.99).

@mpulkki-mapbox Opened a new ticket for discussion of this issue: #11956

@ansis
Copy link
Contributor Author

ansis commented Jun 6, 2022

This is caused by transform.recenterOnTerrain which should be disabled if the globe view is active.

Does 320bf81 look right?

@ansis
Copy link
Contributor Author

ansis commented Jun 6, 2022

I'm noticing that around level 4, #11353 is still quite visible. Should we consider continuing this behavior past zoom level 5 or is this outweighed by the issues with styling and tile loading?

The zoom range is adjusted by const t = getProjectionInterpolationT(this, 1024); to account for change in viewport size. If the viewport is smaller, start earlier. For globe view it's currently limited to not change further past 1024 in order to make sure it's done before the globe-to-mercator transition.

Fixing this visible scaling at z4 for massive maps would mean either:

  • making the globe-to-mercator transition range dynamic based on viewport size
  • maintaining scale during panning and changing zoom level here

Both are reasonable options, but I think we may want to put this off for now. (Massive maps also have pretty bad performance...)

@SnailBones
Copy link
Contributor

Fixing this visible scaling at z4 for massive maps would mean either:

* making the globe-to-mercator transition range dynamic based on viewport size

* maintaining scale during panning and changing zoom level here

One option to add would be moving the globe-to-mercator transition to a higher zoom per discussion in https://github.com/mapbox/gl-js-team/issues/352.

@ansis ansis force-pushed the ansis/globe-scaling branch from 320bf81 to 93d4fe3 Compare June 6, 2022 18:12
Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

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

LGTM 🟢 but let's hold merging until @mpulkki-mapbox has a chance to review again.

On the topic of gestures, there's a very slight improvement that we could look at: it appears that panning requires a stronger pan distance and has less inertia when done around the poles compared to the equator during the zoom range where the scale adjustment is active.

It's a very subtle issue so it might not be visible to most users, but that's something I noticed when comparing against the older behavior.

Copy link
Contributor

@mpulkki-mapbox mpulkki-mapbox left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@karimnaaji karimnaaji merged commit 3424632 into main Jun 7, 2022
@karimnaaji karimnaaji deleted the ansis/globe-scaling branch June 7, 2022 16:04
karimnaaji pushed a commit that referenced this pull request Jun 7, 2022
* adjust scale at low zoom levels in globe view

* improve

* Adding render test catching missing tiles with minzoom

* Allowing lower zoom level tiles toward the poles

* Fix lint

* Updating render tests to pass

* Updating tolerances to fix failing tests

* Updating one more tolerance

* Fixing query tests

* use GLOBE_ZOOM_THRESHOLD_MIN

* rename to mercatorScaleRatio

* add comment about matching scale

* avoid recentering on terrain if rendering globe

* update unit tests

* lint

Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com>
karimnaaji added a commit that referenced this pull request Jun 8, 2022
* Add fog render test for empty update parameters (#11900)

* Add precision qualifiers to globe_raster fragment shader (#11903)

* Add filter features within map view with globe release test (#11888)

* add filter features within map view with globe release test

* Fix incorrect circle bucket up direction (#11904)

* Fix for https://github.com/mapbox/mapbox-gl-native-internal/issues/3426

* Update baselines

* ScaleControl: add i18n support (#11850)

* ScaleControl: add i18n support

* hardcode nautical miles as `nm` for all locales

* Add minimum/maximum fields for center/parallels (#11912)

* Add new render test for globe antialiasing (#11933)

* Fix potential flickering on image source updates (#11928)

* Fix flickering of image source on reload

* Add unit tests

* Fix setStyle breaking with globe view (#11913)

* set draping for terrain

* use map option for terrain draping check

* move to one line

* wip: add render test

* fixed error with render test

* demonstrate issue with mercator

* fix background id to update in second setStyle call

* bring zoom out to show sphere

* Updating expected.png

* better readability

* fix conditional

* fix lint

Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com>

* Fix tiles not rendering across antimeridian in globe (#11943)

* Add video to globe release tests (#11929)

* add ozone video on globe to release tests

* formatting

* formatting

* fix lint issues

* simplify play/pause button

* added atmosphere

* Do not render atmosphere when fog isn't supported by the projection (#11947)

* Clone stylesheet to allow toggling different styles with `setStyle` (#11942)

* clone stylesheet instead of manipulating it directly

* style should not contain terrain since it is no longer being overwritten

* add unit test

* add in default values for terrain when updating

* Add test for projections

* unit test for terrain exaggeration does not need sources

* should have two calls to setStyle to fully test toggling

* default value does not need to be added if previous terrain style also used the default value

* hasOwnProperty is already a boolean

* no need to check currSpec because checks for deep equals and 1 is already set for default

* fix unit tests

* fix style setting in unit test

* accidental deletion

* switch to deep clone from extend

* better way to find default value

* use hasOwnProperty instead

* convert to false from undefined

* create reusable function for setting transition parameters

* update _setTransitionParameters

* mix up between duraton/delay values

* reduce repetitive code to update style spec and transitions between terrain and fog

* revert change

* minimize scale changes when panning in globe view (#11951)

* adjust scale at low zoom levels in globe view

* improve

* Adding render test catching missing tiles with minzoom

* Allowing lower zoom level tiles toward the poles

* Fix lint

* Updating render tests to pass

* Updating tolerances to fix failing tests

* Updating one more tolerance

* Fixing query tests

* use GLOBE_ZOOM_THRESHOLD_MIN

* rename to mercatorScaleRatio

* add comment about matching scale

* avoid recentering on terrain if rendering globe

* update unit tests

* lint

Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com>

* Do not set the map language to the user's preferred language by default (#11952)

* Do not set the map language to the user's preferred language by default

* fix unit test

* cleanup

* cleanup

* fix worldview setter

Co-authored-by: Mikko Pulkki <55925868+mpulkki-mapbox@users.noreply.github.com>
Co-authored-by: Anna Peery <42715836+avpeery@users.noreply.github.com>
Co-authored-by: Stepan Kuzmin <stepan.kuzmin@mapbox.com>
Co-authored-by: Tristen Brown <tristen@users.noreply.github.com>
Co-authored-by: Aidan H <aidan.hendrickson@mapbox.com>
Co-authored-by: Ansis Brammanis <ansis@mapbox.com>
@karimnaaji
Copy link
Contributor

@mpulkki-mapbox @endanke , the behavior adopted here hasn't been propagated in the mobile SDKs, and it has been reported as mismatching between web and native platform by some users (especially for those trying to get a consistent user experience between web and mobile on end customers products). Should we keep track of this change to back-port for consistency between the SDKs? Unless there is any reason we shouldn't adopt the same behavior on mobile.

@endanke
Copy link
Contributor

endanke commented Nov 29, 2022

@karimnaaji as I see this PR was ported by Mikko to GL-Native: https://github.com/mapbox/mapbox-gl-native-internal/pull/3574 (This was part of 10.7 so it's worth to check if the customer was using that version.)
Or do you mean that it would require some other changes in the platform SDKs?

@karimnaaji
Copy link
Contributor

Thanks for confirming @endanke , it's possibly a mismatching customer version, I'll check and confirm with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Used for PRs that do not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected zooming when panning up or down on globe
5 participants