emscripten-core / emscripten-core/emscripten
Screen orientation lock fail on modern browser
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
The HTML5 Emscripten functions around locking the screen orientation, like:
- `emscripten_lock_orientation`
- `emscripten_unlock_orientation`
- `emscripten_get_orientation_status`
based on the [old API](https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation) (`screen.lockOrientation`), which is now deprecated and removed from modern browsers, and replaced by the new [Screen Orientation API](https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation) (`screen.orientation.*`). This causes that this functionality does not work on current version of most available browsers.
It would be nice to add support to the new API in Emscripten.
Anyway, there is also **a problem in the current implementation that can lead to crashes/bugs**. As both APIs use the same name - `screen.orientation`, calling `emscripten_get_orientation_status` in a modern browser will fail and cause a memory error due to access to invalid data - instead of the expected lock type (`string`) it will get ref to object that exposed the new interface (`ScreenOrientation`).
Contributor guide
Assessment
This issue has not been assessed yet.