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

Improve full screen mode on Safari #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

st3fan
Copy link

@st3fan st3fan commented Jan 30, 2022

Draft patch because I have not been able to properly test this in all emulators yet.

This patch was written from an archive.org perspective and fixes two problems in loader.js:

Calling requestFullscreen

When running Safari, when you hit the Full Screen View button on an active emulator, the following error happens:

TypeError: this._canvas.requestFullscreen is not a function. (In 'this._canvas.requestFullscreen()', 'this._canvas.requestFullscreen' is undefined)

This is because EmscriptenRunner.requestFullScreen calls requestFullscreen on the Canvas instead of going through getfullscreenenabler(), which will pick the available (prefixed) version of requestFullscreen.

Adjusting the canvas scale

With the first part in place, things work (at least in vMac) but are not scaled properly. This is hard to see on a 16:9 screen but it becomes very obvious on different screen sizes.

The problem is the following, which happens after the canvas is made full screen:

ReferenceError: Can't find variable: scale

This is because the fullScreenChangeHandler (in Emulator.setupFullScreen) can't reference the variables it needs because they are under this, which gets lost in the callback. The usual trick is to move this in a new variable and then capture that in the callback - that seemed to already be in the code (let self = this;) partially but is not actually used in the callback.

@st3fan
Copy link
Author

st3fan commented Jan 30, 2022

There is something really odd happening in Safari it seems the emulator goes into fullscreen mode a couple of times. And when you exit (by hitting escape) the browser seems very confused about the full screen state.

I thought it had something to do with the onwebkitfullscreenchange callback but even with that fully commented out it still happens.

@st3fan
Copy link
Author

st3fan commented Jan 30, 2022

Interestingly when I patch archive.org, the weird Safari thing where it goes in and out of fullscreen mode multiple times does not happen.

Go to for example https://archive.org/details/hypercard_virus-reference-214

Then in the web inspector, alias requestFullscreen to webkitRequestFullscreen:

c = document.getElementById("canvas")
c.requestFullscreen = c.webkitRequestFullscreen

Now you can succesfully put the emulator in full screen mode. Except the scaling / aspect ratio is broken because of the second bug. (I don't know how to hot-patch that to try)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant