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

Fix an edge case with loadImage in Safari and older Firefox #10524

Merged
merged 1 commit into from
Mar 30, 2021

Conversation

mourner
Copy link
Member

@mourner mourner commented Mar 30, 2021

Fixes #10180 by getting data out of an Image object eagerly when running loadImage in case ImageBitmap is not supported.

In the stretchable images example, loadImage result was saved to be used later (when both images are loaded), and there could be a situation where the image memory is freed (with the transparent image hack) before it gets passed to addImage. This PR fixes this by doing getImageData as soon as we load the image, not later at the addImage stage, when using the combination of loadImage and addImage with a delay in between.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality — need to see if it's possible to unit-test this properly
  • manually test the debug page
  • 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>Fixed a bug where map.loadImage followed by map.addImage with a delay could fail in Safari and Firefox.</changelog>

Sorry, something went wrong.

@mourner mourner requested a review from ryanhamley March 30, 2021 18:13
@ryanhamley ryanhamley merged commit 199613d into main Mar 30, 2021
@ryanhamley ryanhamley deleted the fix-load-image branch March 30, 2021 19:53
@ghost
Copy link

ghost commented Mar 31, 2021

Will this be backported to 1.13?

@vepr-ua
Copy link

vepr-ua commented Jun 7, 2021

This would be a good idea to be backported to 1.13. We can't switch to v2 as we need IE support and the v1 worked just fine.

@mourner
Copy link
Member Author

mourner commented Jun 8, 2021

@VeprUA this was already backported and included in v1.13.1, unless you're hitting another related issue?

@vepr-ua
Copy link

vepr-ua commented Jun 8, 2021

Appreciate this. Sorry didn't see there was a new version update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stretchable images inc. example not working in Mac OS Safari & Firefox, Chrome OK
4 participants