-
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
Failed to invert matrix error #6486
Comments
Hi @rulyotano, sorry to hear you're running into a problem. does this happen randomly for you on mapbox examples, or in application code you've written? If the latter, can you try and create a minimal, self-contained (no 3rd party libraries or code unrelated to reproducing the map error) example on jsfiddle or jsbin? |
Hi @mollymerp, in response to you: does this happen randomly for you on mapbox examples, or in application code you've written?: it happens randomly in code that I have written I'm also using a custom style. Why do I think it is an issue?: 1) It happens randomly, 2) Happens when making zoom in/out. I have doesn't seen the error on examples, I will try to reproduce. Thanks |
It might not be the same issue but I can get an error like this by doing very rapid map panning/pitching/rotating when zoomed out as much as possible similar to what you describe.
Mind you it doesn't cause me any noticeable issues as a user. @rulyotano do you notice this actually causes any issues to the user? |
@andrewharvey that is the main problem, it is a big issue for the user, because stops the complete map functionality, it stops working. Even the entire webapp can break due to micro-overprocessing. The It is very difficult to me to reproduce the issue, even in my code, it happens just a very few times, and, I think, is randomly. I don't know if it happens when chrome is very memory loaded, or after making a map rotate, etc. What I would expect, is that if some error like that happens, it doesn't block the entire map. |
Your bug must be different to the one I saw, since for me the map still works fine even after the error. Without identifying the exact cause I wonder if we should band-aid it by just being more proactive in checking function arguments look reasonable all the way up your stacktrace? |
I got the error again, but this time with an complete empty map, only by making zoom in/out. I'm going to paste the the code of my
|
@rulyotano thanks for following up! can you put the empty map example that reproduced the error on jsbin or jsfiddle please? |
@mollymerp I will try, but I repeat, it is raised very randomly. |
I concur, as I mentioned I see the same error on even the simple map example, so it's nothing from the application code causing this. One option would to try to be more defensive, ie. check inputs to each function match what is expected, but this might decrease performance, so it might be best to try to identify the exact source of the error. |
I'm getting the exact same error in Sentry reports, with 0.45.0. One line of
And then countless:
I have no idea how to reproduce it, as I'm only seeing this via Sentry reports. |
Here is a non-minified Sentry trace about this issue. All of them look the same, it's something with mouse wheel zoom calculation. I think what is happening is that some calculation makes the target value to be NaN. At least it is possible to trigger this issue by setting zoom to NaN on this line: mapbox-gl-js/src/ui/handler/scroll_zoom.js Line 235 in 1a8e9fe
Thus I guess a very simple and safe fix would be to check if the interpolated value is NaN or not. |
Yes, looking more at the code, if any of What do you think about simply making:
|
I think that would be a solution, thanks a lot and for the pull request
accepted! 👍👍👍
|
Also, an other bug, in the same lines.
https://sentry.io/share/issue/0d51616d29b04425a3dca5b4a77a4916/ For me it seems logical that if |
Yes, the most trivial way scrolling can get into illegal matrix is via these 3 lines: mapbox-gl-js/src/ui/handler/scroll_zoom.js Lines 223 to 226 in e8bc616
|
see: mapbox#6924 Closes mapbox#6782 Closes mapbox#6486 Replaces mapbox#6921
I'm getting the exact same error in Sentry reports, with 1.2.0. |
I was getting the same error "Uncaught Error: failed to invert matrix". It turned out to be a syntax mistake from my side while calculating new zoom level:
This line caused the newZoom to be invalid, since brackets were missing:
This line works fine. Just in case, someone has similiar code and might have made the same mistake. |
I was getting this error when trying to implement point clusters per this tutorial: https://docs.mapbox.com/mapbox-gl-js/example/cluster/ I solved the problem by adding a check for an undefined zoom param here:
|
After may code changes, adding corrrect sequence in Authorisation for gps, deviceorientation etc I made the above code change in checking on !isNaN on the zoom in map.easeTo .... looks like the endless NaN error of InvertMatrix etc is gone.... thanks for the hint ! |
The error still in version v0.44.2.
If it helps, I also get the same error on random occasions when making zoom in/out by using mouse scroll for instance. First is raised a
failed to invert matrix
error, and then, on every action in the map, for instance moving the mouse over, is raised this error:Invalid LngLat object: (NaN, NaN)
. Call Stack for this last error:Seems that the problem in this last error is when trying to convert the point to coordinate, in the line
return this.coordinateLocation(this.pointCoordinate(p))
thethis.pointCoordinate(p)
is returningCoordinate {column: NaN, row: NaN, zoom: NaN}
. It is difficult to reproduce the error, because it is random, if any new detail I will update this post or create a new one.Details of
failed to invert matrix
error:The line:
Question, what about if
this.pixelMatrix
isn't invertible? Has that any logic?The text was updated successfully, but these errors were encountered: