Repository navigation
fix(google-maps): don't crash on a zero-width vector map - #10848
Open
Juice-de-Orange wants to merge 1 commit into
Open
Juice-de-Orange wants to merge 1 commit into
Juice-de-Orange wants to merge 1 commit into
Conversation
getViewPropsFromCoordinateTransformer only guarded against a zero height, so a vector map that briefly reports a width of 0 produced aspect 0 and a non-invertible projection matrix, and the next draw threw "Cannot read properties of null (reading '0')". Fall back to aspect 1 unless both dimensions are positive. Closes visgl#10596 Co-authored-by: Christian Kaisermann <12702016+kaisermann@users.noreply.github.com>
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10596
Change List
getViewPropsFromCoordinateTransformer: require positive width and height foraspectFix and test are from @kaisermann's report (co-author on the commit). Verified with
yarn vitest run --project=headless test/modules/google-maps/: the new test fails onmasterwith theTypeErrorfrom the issue and passes with the fix. A temporary test running the 800x600 → 800x0 → 0x0 → 0x600 → 800x600 sequence from the issue no longer throws at 0x600.Note
Low Risk
Single-line guard in vector-map view projection math plus a regression test; no auth, data, or API surface changes.
Overview
Fixes crashes when a vector Google Map is drawn at zero width (e.g. during resize) by hardening camera/projection setup in
getViewPropsFromCoordinateTransformer.Aspect ratio now uses
width / heightonly when both dimensions are positive; otherwise it falls back to1. The previous check only guarded onheight, so a zero-width map with non-zero height could still produce an invalid aspect and throw duringdraw.Adds a headless test that mounts
GoogleMapsOverlayon a0×600vector map and assertsmap.draw()does not throw.Reviewed by Cursor Bugbot for commit ccb5b3f. Bugbot is set up for automated code reviews on this repo. Configure here.