CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.05k stars 3.51k forks source link

WebGL in workers via OffscreenCanvas #6896

Open mramato opened 6 years ago

mramato commented 6 years ago

WebGL in Workers is happening soon (via OffscreenCanvas). Chrome is adding support and talks about it here (see Canvas section) https://blog.chromium.org/2018/08/chrome-69-beta-av1-video-decoder-css.html

I couldn't find any issue, but I know this is something we've talked about in the past. Please post any thoughts/ideas about how you think we may be able to leverage this (and if anyone has time, feel free to investigate further).

mramato commented 6 years ago

Here's more info and some tutorial/demo code: https://developers.google.com/web/updates/2018/08/offscreen-canvas

9oelM commented 4 years ago

@mramato I'm very interested in making cesium work in OffscreenCanvas. Currently, I can find no viable method to make all rendering process happen in OffscreenCanvas (although some non-DOM-element-access operations are already done from the worker side in Cesium). Perhaps there will be some changes needed for the cesium engine in order to get the basic things work in it... but I don't know how. Could anybody point me to the right direction? This will be really needed anyways for anybody in the future. In essence, my questions are:

  1. Is Cesium team going to work on this?
  2. How can I make a custom renderer that utilizes OffscreenCanvas in Cesium?

Thank you for all your great help in advance.

OmarShehata commented 4 years ago

@9oelM this isn't on our immediate roadmap, so I'd say go for it if this is something you need (and if you can contribute back a pull request that'd be great!)

The good news is CesiumJS's rendering architecture is pretty well abstracted so this may not be as huge of an architectural change as it may seem. This blog explains this architecture well: https://cesium.com/blog/2015/05/15/graphics-tech-in-cesium-architecture/

If you're working on this I'd start a topic in the community forum and link to it from here to see if others want to collaborate or help along the way: https://community.cesium.com/

jjhembd commented 1 year ago

Until recently, this has not been feasible due to lack of support in Safari. As of today, MDN says .getContext doesn't work in an OffscreenCanvas. But caniuse.com says offscreen drawing support was added in Safari 16.4 (3 weeks ago).

One possible use case: pre-rendering vector tiles in a worker, which could then be draped on the terrain in the main thread. See #2132.

mivui commented 1 year ago

whether support or not