Three.js: Offscreencanvas example is broken in Chrome <= 79 due to modules in workers

Created on 2 Mar 2020  路  4Comments  路  Source: mrdoob/three.js

Description of the problem

The offscreencanvas example is broken in Chrome 79 and below. This is because it loads a module in the worker, which is not supported in those versions.

https://threejs.org/examples/?q=offsc#webgl_worker_offscreencanvas

Uncaught TypeError: Failed to construct 'Worker': Module scripts are not supported on DedicatedWorker yet. You can try the feature with '--enable-experimental-web-platform-features' flag (see https://crbug.com/680046)
    at webgl_worker_offscreencanvas.html:89

It looks like it is only supported from Chrome 80+ (https://dev.to/uhligtobias/chrome-v80-release-js-module-support-for-workers-5cnf).

What is the minimal browser version we want to support for the examples?

Three.js version
  • [x] Dev
  • [x] r114
Browser
  • [ ] All of them
  • [x] Chrome 79 and below
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Question

All 4 comments

What is the minimal browser version we want to support for the examples?

There is no such a requirement/convention. Some examples use (experimental) APIs which are not supported by all browser or disabled by default. The AR demos are a good example for this.

Since latest Chrome supports module usage in workers by default, it made absolutely sense to migrate the code to modules. Especially since it's just a matter of time until other browser support the demo, too.

@Tirzono What's you situation? Why do you need to support Chrome 74?

I don't necessarily need support for Chrome 74. I just noticed it that from one day to the other the example was not working anymore and I was not sure if you would be aware. For me personally I am most of the time working in an environment with the latest version of the browsers, but just now I was in an environment that doesn't allow me to use the latest browser and noticed this issue.

When running an older browser not having offscreencanvas support it shows a message nicely about the fact it cannot be shown, but it doesn't show a nice message when modules in workers are not supported. It's nitpicking, but we could show a message that the browser is not supported, just like we show a message if offscreencanvas is not supported. But I don't know how necessary that is as for most people their browser does auto update I guess.

I also tested other versions of Chrome and it looks like the versions of 79 and below don't support modules in workers.

Since latest Chrome supports module usage in workers by default, it made absolutely sense to migrate the code to modules. Especially since it's just a matter of time until other browser support the demo, too.

I do agree it makes sense to move to modules in workers, so I think making that change was a good choice. The examples will be mostly visited by developers anyway and they most of the time have the latest versions installed.

I also tested other versions of Chrome and it looks like the versions of 79 and below don't support modules in workers.

https://chromestatus.com/feature/5761300827209728

Was this page helpful?
0 / 5 - 0 ratings

Related issues

makc picture makc  路  3Comments

zsitro picture zsitro  路  3Comments

alexprut picture alexprut  路  3Comments

clawconduce picture clawconduce  路  3Comments

boyravikumar picture boyravikumar  路  3Comments