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

IE11 support broken due to emscripten issue #96

Closed
tomdrewes opened this issue Mar 6, 2018 · 7 comments
Closed

IE11 support broken due to emscripten issue #96

tomdrewes opened this issue Mar 6, 2018 · 7 comments

Comments

@tomdrewes
Copy link

I noticed that I was seeing an "Object expected" error in sass.worker.js when running on IE11. It appears there is an issue in recent versions of emscripten that is causing this:

emscripten-core/emscripten#6204

They cite passing the -s LEGACY_VM_SUPPORT=1 to emcc as a workaround. I've tested this and it does work. Apparently, there is also an open pull request to incorporate a fix into default emscripten output.

Just wondered if in the interim it might make sense to add the LEGACY_VM_SUPPORT flag to libsass/Makefile.patch in order to restore IE11 support.

tomdrewes added a commit to tomdrewes/sass.js that referenced this issue Mar 6, 2018
@rodneyrehm
Copy link
Member

Thanks for not only reporting a problem but also figuring out the solution!

I'm currently looking into getting libsass 3.5.0 to work on top of 0.11.0-beta.1 which switches to WebAssembly. Does the IE11 problem also occur in that version? would -s LEGACY_VM_SUPPORT=1 also solve the problem there?

@rodneyrehm
Copy link
Member

Nevermind… IE11 doesn't like the current WASM build at all :D

no native wasm support detected
no binaryen method succeeded. consider enabling more options, like interpreting, if you want that: https://github.com/kripken/emscripten/wiki/WebAssembly#binaryen-methods

@tomdrewes
Copy link
Author

I discovered the same. :-)

IE11 doesn't support native WebAssembly:
https://caniuse.com/#feat=wasm

And running a build from 0.11.0-beta.1 on IE11 results in the following error:
no native wasm support detected
SCRIPT0: abort("no binaryen method succeeded. consider enabling more options, like interpreting, if you want that: https://github.com/kripken/emscripten/wiki/WebAssembly#binaryen-methods"). Build with -s ASSERTIONS=1 for more info.
sass.worker.js (5,1)

It appears that for webasm to work, you'll have to define some alternative binary loading method to support IE11:
https://github.com/kripken/emscripten/wiki/WebAssembly#binaryen-methods

If the alternative was asm.js, I'd imagine the same LEGACY_VM_SUPPORT flag would apply.

@rodneyrehm
Copy link
Member

alright, as 3.5.0 seems to work without a problem I guess it's IE11 time…

@rodneyrehm
Copy link
Member

Hey @tomdrewes, sorry for the insane delay. I've added the flag and released 0.10.11.

@tomdrewes
Copy link
Author

tomdrewes commented Sep 25, 2018

Thanks for the fix @rodneyrehm. The change works on my setup, however, the upgrade to emscripten 1.38.12 seems to have added another IE/Edge wrinkle for web workers. I'll just briefly summarize here in case anyone else runs into the issue:

The loader for emscripten in sass.worker.js tries to create a "random_device" from which it can summon random numbers. It derives this from the crypto API which comes in various flavors via the window object and for some web workers via self. Unfortunately, IE and Edge do not support crypto (nor the prefixed msCrypto) on web workers (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7607496/). In earlier versions of emscripten, it appears the loader would just patch in a pseudo-random number generator (not cryptographically secure, which may have been the reason for changing things in the more recent emscripten release) but in the current version, if it can't find the crypto API, it aborts with a message similar to the following:

random_device

SCRIPT0: 6439624
sass.worker.js (5,1)

As a workaround in my application I am prepending a shim on sass.worker.js for missing crypto which does basically this (some details omitted):

if (!self.crypto) {
    self.crypto = {
        getRandomValues: function(array) {
            for (var i = 0, l = array.length; i < l; i++) {
                array[i] = Math.floor(Math.random() * 256
            }
            return array;
        }
    };
}

This is, of course, not cryptographically secure, so one should not use this in an application that depends on such properties! I do not see any references to random_device in the rest of the sass.worker.js code, however, so this seems like a reasonably safe approach.

@Johann-S
Copy link
Contributor

Johann-S commented Sep 28, 2018

Thanks @tomdrewes for you fix, but It fix the issue only for Edge and not IE 11.

I would like to know if we'll have an official solution for that issue ? (I'm facing too)

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

No branches or pull requests

3 participants