-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fixing matrix errors #6782
Comments
see also #6486 |
Two more paths for an illegal matrix error.
Causes an exception and later an assertion error, but I believe this doesn't propagate to illegal matrix error. |
What would you like to be the solution here? I can make a PR for adding
to set zoom. This would solve all the problems in practice, as a quick term solution. A better solution of revised scroll logic should still be considered in the future though. |
see: mapbox#6924 Closes mapbox#6782 Closes mapbox#6486 Replaces mapbox#6921
Failed to invert matrix errors are quite bad, as they get the UI in a "stuck" state, where no interaction have any effect. Effectively the map part of the application is frozen.
I've been debugging how do they happen using Sentry in a live production site, as otherwise I couldn't reproduce it on my machine, but they happen very regularly to users (across all kind of browsers).
There are multiple ways a map can get into this illegal state, here is the most common one:
scroll_zoom / _onScrollFrame / delta !== 0 is not run first. This means that
this._targetZoom
is not initialized.mapbox-gl-js/src/ui/handler/scroll_zoom.js
Line 207 in b9e32bf
interpolate receives a value with
undefined
as the second parameter. The way interpolate is written, it'll turn this intoNaN
, even if k is 0.mapbox-gl-js/src/ui/handler/scroll_zoom.js
Line 235 in b9e32bf
geo / transform / set zoom has a guard for making sure a value is between min and max zoom, but this guard doesn't protect against NaN.
mapbox-gl-js/src/geo/transform.js
Line 161 in b9e32bf
NaN goes through setZoom and just kills the matrix calculations.
Recommendations:
guard at the first line.
Interpolate could return a value without calculation if t is 0 or 1, both as an optimization as well as making it more reliable.
scroll_zoom should be fixed so that _targetZoom and _easing is always initialised.
@anandthakker @mourner @jfirebaugh
The text was updated successfully, but these errors were encountered: