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

[#4340] Fixes possible access to undefined object #4431

Merged
merged 4 commits into from
Jul 22, 2024

Conversation

birdofpreyru
Copy link
Contributor

@birdofpreyru birdofpreyru commented Jul 19, 2024

Fixes regression in the latest v4.5.0 release —
Fixes #4340.

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • 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.
  • Add an entry to CHANGELOG.md under the ## main section.

@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.79%. Comparing base (4b98e75) to head (efb08cf).
Report is 5 commits behind head on main.

Files Patch % Lines
src/render/painter.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4431      +/-   ##
==========================================
+ Coverage   87.57%   87.79%   +0.22%     
==========================================
  Files         246      246              
  Lines       33396    33396              
  Branches     2223     2184      -39     
==========================================
+ Hits        29247    29321      +74     
+ Misses       3130     3076      -54     
+ Partials     1019      999      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Jul 19, 2024

Any chance you could create a unit test to cover this scenario?

@birdofpreyru
Copy link
Contributor Author

@HarelM I have added the test.

I also got a better idea, why the problem happened — when a new Style instance is set on the map, the painter's render() method might be called before the style's asynchronous loadURL() operation completes, and the stylesheet value is attached to the style only when loadURL() completes, inside the _load() method it calls.

It makes me think, perhaps there is a larger problem, and in the perfect world, something should be synchronized better, so that the style is not set on the map before the style is loaded, or render() is not called before the map style is loaded... but regardless, my PR hotfixes the problem with library crashing.

Copy link
Collaborator

@HarelM HarelM left a comment

Choose a reason for hiding this comment

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

THANKS

@HarelM HarelM merged commit 52e7962 into maplibre:main Jul 22, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of undefined (reading 'sky')
3 participants