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

Remove the web worker to allow for direct DOM access from scripts #581

Open
KallynGowdy opened this issue Dec 16, 2024 · 0 comments
Open
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

Comments

@KallynGowdy
Copy link
Member

KallynGowdy commented Dec 16, 2024

Currently, CasualOS scripts run inside a web worker inside an iframe.

This original design was made to enforce two key things:

  1. Security boundary (iframe)
  2. Process boundary (web worker)

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:

  1. The VM has to be loaded from a separate domain from the frontend. According to Chrome rules, iframes get a separate process if the site is different (different domain - does not include subdomains - sub.casualos.com is the same as casualos.com according to the rules, but example.com is different from casualos.com)
@KallynGowdy KallynGowdy converted this from a draft issue Dec 16, 2024
@KallynGowdy KallynGowdy added enhancement New feature or request area:runtime Is related to the CasualOS runtime. (Everything in aux-runtime, aux-common, aux-vm, etc.) area:player Is related to the player frontend. (Everything in aux-server/aux-web/aux-player) labels Dec 16, 2024
@KallynGowdy KallynGowdy moved this from To triage to Backlog in CasualOS Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: Backlog
Development

No branches or pull requests

1 participant