Skip to content

Commit 50adf1c

Browse files
Ryan Hamleymourner
andauthored
Fix ImageSource not working in Firefox and Safari
Co-authored-by: Vladimir Agafonkin <[email protected]>
1 parent f87090b commit 50adf1c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.13.1
2+
3+
### 🐞 Bug fixes
4+
- Fix ImageSource not working in some cases in Firefox & Safari. [#10230](https://github.com/mapbox/mapbox-gl-js/pull/10230)
5+
16
## 1.13.0
27

38
### ✨ Features and improvements

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mapbox-gl",
33
"description": "A WebGL interactive maps library",
4-
"version": "1.13.0",
4+
"version": "1.13.1",
55
"main": "dist/mapbox-gl.js",
66
"style": "dist/mapbox-gl.css",
77
"license": "SEE LICENSE IN LICENSE.txt",

src/util/ajax.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,11 @@ function arrayBufferToImage(data: ArrayBuffer, callback: (err: ?Error, image: ?H
280280
img.onload = () => {
281281
callback(null, img);
282282
URL.revokeObjectURL(img.src);
283-
// prevent image dataURI memory leak in Safari
283+
// prevent image dataURI memory leak in Safari;
284+
// but don't free the image immediately because it might be uploaded in the next frame
285+
// https://github.com/mapbox/mapbox-gl-js/issues/10226
284286
img.onload = null;
285-
img.src = transparentPngUrl;
287+
window.requestAnimationFrame(() => { img.src = transparentPngUrl; });
286288
};
287289
img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));
288290
const blob: Blob = new window.Blob([new Uint8Array(data)], {type: 'image/png'});

0 commit comments

Comments
 (0)