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

Detect if the browser supports pthreads to pick the most suitable execution mode #5

Open
thomasgoldstein opened this issue Sep 14, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@thomasgoldstein
Copy link

Hi. A feature request. Add the ability to create a lovejs bundle which would contain both the pthread version and the compatibility version, and at the beginning of the execution, it'd detect if your browser supports pthreads in order to pick the best version.

@Davidobot
Copy link
Owner

I've looked into this a bit. Looks like there is no direct check for pthreads support. The way to implement this would probably be to catch all exceptions from the main loop and switch versions if they are encountered.

@thomasgoldstein
Copy link
Author

I've looked around. I don't know if it's relevant here, but I've found this: whatwg/html#4732
Some people suggest ways to detect SharedArrayBuffer support, but I'm not even sure that it's the same as pthread support.

If that is not useful, here's another idea: maybe it'd be simpler to just call some dummy pthread init code on startup to know right away if it's supported or not by the browser, so you don't have to bother trying to catch exceptions that might arise later while playing the game.

@jiaaro
Copy link

jiaaro commented Sep 16, 2020

window.SharedArrayBuffer === undefined does seem to coincide with browsers where the compat version is required in my limited testing. Seems like a good enough heuristic. I'd want to fall back to compat aggressively to ensure things run.

@Davidobot Davidobot added the enhancement New feature or request label Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants