12

I am trying to run a blazor application in Internet Explorer. On the blazor page there is a notification stating there is a fallback into asm.js for browsers without webassembly support. When I load the page in IE (with blazor.pollyfil.js script linked), I just get the error "Browser doesn't support WebAssembly".

I am able to run the application in server mode (using a SignalR connection to rendering server) but it is a solution for all browsers and loses the benefits of web assembly.

Is there a way to correctly fall back to asm.js mode, only in Internet Explorer?

sanepete
  • 979
  • 9
  • 28
Fanda
  • 3,760
  • 5
  • 37
  • 56

3 Answers3

10

Support for asm.js was intentionally removed from Blazor in this commit: https://github.com/aspnet/Blazor/commit/4006cd543900fcc1cf76cd75a1b24007e60c8a67 . If I understand correctly, getting asm.js support back from stock blazor would require the mono project to start including an asm.js build in its binary distribution and for the Blazor project to add that back to its build/deploy tooling.

I haven’t tried it, but it might be possible to build mono for asm.js yourself and inject it into your built Blazor application as part of your own deploy process.

If I understand correctly, Blazor still runs using mono’s interpreted mode, so supplementing the wasm build of mono with an asm.js one might still be sufficient. If Blazor switches to actually compiling assemblies to wasm directly in the future, things will become more complicated.

Alternatives

Blazor supports server-side hosting mode. You already mentioned this in your question, but I am discussing this here in case others skipped over that. In server hosting mode, the client only needs to be able to run “traditional” JavaScript (though it may need polyfills). This can be made to work in IE11 and other clients lacking wasm support. Of course, this takes more resources on the server, prevents the client from supporting offline scenarios, and is basically like a glorified telnet session. But this may be sufficient for LOB applications.

binki
  • 7,754
  • 5
  • 64
  • 110
3

WebAssembly is not included in Internet Explorer features. You can learn about browser compatibility at mozilla.org, and no, IE has no support for WebAssembly.

enter image description here

Remember IE is discontinued, but still maintained:

Will Internet Explorer 11 continue to receive updates?

The latest features and platform updates will only be available in Microsoft Edge. We will continue to deliver security updates to Internet Explorer 11 through its supported lifespan. To ensure consistent behavior across Windows versions, we will evaluate Internet Explorer 11 bugs for servicing on a case by case basis.

Changing from WebAssembly to component mode is just a few lines change code, but seems weird to deploy both modes to keep compatibility for IE. Remember Blazor is experimental, I guess for a real deployment you should to wait for a while... time to update from IE to some other browser.

Is there really way how to correctly fall back to asm.js mode in (only) Internet Explorer?

I guess is the same question as "How can I check if a browser supports WebAssembly?", just adapt the answer for Blazor:

const isClientSideWebAssemblySupported = (() => {
    try {
        if (typeof WebAssembly === "object"
            && typeof WebAssembly.instantiate === "function") {
            const module = new WebAssembly.Module(
                               Uint8Array.of(0x0, 0x61, 0x73, 0x6d,
                                             0x01, 0x00, 0x00, 0x00));
            if (module instanceof WebAssembly.Module)
                return new WebAssembly.Instance(module) 
                           instanceof WebAssembly.Instance;
        }
    } catch (e) {
    }
    return false;
})();

var script = document.createElement('script');
script.src = (isClientSideWebAssemblySupported)?
             "_framework/blazor.server.js":
             "_framework/blazor.webassembly.js";

Remember to include both js in your project.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
dani herrera
  • 48,760
  • 8
  • 117
  • 177
  • Everything you wrote I know, but the question remains. Fallback to asm.js in browsers without WebAssembly support... – Fanda Nov 26 '18 at 10:56
  • hi @Fanda, I wrote a kind of approach to your question. Take a look. I don't know if this is a solution to you, let me now to improve or delete my answer. – dani herrera Nov 26 '18 at 11:12
  • Your script pointed me to the solution. Can be seen on github: https://github.com/frantiseksidak/BlazorWithFallback – Fanda Nov 28 '18 at 22:00
  • You don’t address the question which is: Blazor promised that it would run on asm.js (which runs on all browsers). How do I get a build of my Blazor app which uses an asm.js build of mono instead of a WebAssembly one? Is that not supported—does it use a version of mono which compiles to WebAssembly on the fly instead of using interpreter mode? – binki May 14 '19 at 23:27
  • 1
    @binki : Re-reading my answer I see you are right, this answer is not focused on the subject of the question. – dani herrera May 15 '19 at 06:42
0

It looks like other users are also facing this issue.

That user find that the problem is with the polyfills (and Internet Explorer 11 of course), and it occur with babel / core-js and other compatible polyfills.

It seem that IE11 have some difficulties with deep setter recursion on Symbol, and it get a Stack memory exceeded error.

he also try to fix the polyfill. You can try to make a test with it to check whether it help to solve your issue or not.

Reference:

asm.js fallback not working on IE11

Polyfills for Blazor (for Internet Explorer 11 support and some other browsers)

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • This is the blazor.pollyfil.js file I wave already linked, as written in the question. – Fanda Nov 27 '18 at 10:34
  • @Fanda, If you check that link than you can find that it was updated by that user to correct the issue. You can refer the changes in README.md file. So you can have a check whether you had linked the updated polyfill or not. – Deepak-MSFT Nov 28 '18 at 05:13