Remove the web worker to allow for direct DOM access from scripts #581
Labels
area:player
Is related to the player frontend. (Everything in aux-server/aux-web/aux-player)
area:runtime
Is related to the CasualOS runtime. (Everything in aux-runtime, aux-common, aux-vm, etc.)
enhancement
New feature or request
Currently, CasualOS scripts run inside a web worker inside an iframe.
This original design was made to enforce two key things:
This is because that in the past, the iframe was loaded from the same origin (or null origin) as the CasualOS frontend, and not all web browsers use a separate process for iframes that are loaded from the same origin. In other words, while iframes from the same origin still have a security boundary, they are (often) run within the same process which could cause issues if a script runs into an infinite loop. So, to conclude, the iframe was used to ensure that scripts can't touch the frontend stuff directly, and the web worker was used to ensure that scripts always run in a separate thread from the frontend code to prevent lockups.
Now, it is much more common to run CasualOS using a separate origin for the iframe, so most web browsers should run it in a separate iframe. This means that if a separate domain is used for the iframe, we don't need to create the web worker anymore to get a separate thread for running scripts. This in turn means that it is possible to remove the web worker and give direct DOM access to the scripts.
There is really only one caveat:
sub.casualos.com
is the same ascasualos.com
according to the rules, butexample.com
is different fromcasualos.com
)The text was updated successfully, but these errors were encountered: