Three.js: createImageBitmap() not supported in Safari

Created on 22 Aug 2019  路  4Comments  路  Source: mrdoob/three.js

Description of the problem

Unable to create ImageBitmaps in Safari.

Describe the bug or feature request in detail.

THREE.ImageBitmapLoader: createImageBitmap() not supported.

When trying to create image bitmaps in safari gives the above warning and doesn't render the bitmaps.

Three.js version
  • [x] r107
Browser
  • [x] Safari
OS
  • [ ] All of them
  • [x] macOS
  • [x] iOS
Browser Issue

Most helpful comment

three.js does in general not provide polyfills for all used Web APIs (e.g. Promises). It's the application's task to do this if necessary.

All 4 comments

On Safari I use:

if ( ! ( 'createImageBitmap' in window ) ) {

    window.createImageBitmap = async function ( blob ) {

        return new Promise( ( resolve, reject ) => {

            let img = document.createElement( 'img' );

            img.addEventListener( 'load', function () {

                resolve( this );

            } );

            img.src = URL.createObjectURL( blob );

        } );

    };

}

As you can see here, createImageBitmap() is not supported by Safari. So this is a browser issue.

I would argue its not a browser issue as the engine should check if the function is supported and then run other code that does work as a workaround.

three.js does in general not provide polyfills for all used Web APIs (e.g. Promises). It's the application's task to do this if necessary.

Was this page helpful?
0 / 5 - 0 ratings