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

qt: fix cam access by restoring window.isSecureContext #3074

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

benma
Copy link
Contributor

@benma benma commented Nov 26, 2024

In d78380f, we switched from qrc:/ to the bitboxapp:/ custom scheme so we can force mimetypes in the scheme handler. This somehow made window.isSecureContext be false, breaking camera (which requires a secure context).

The issue was that our scheme handler was never registered, because it was configued with HostAndPort but no default port was specified. We could specify one, or switch to Host only, but in our case Path seems to be most appropriate.

The frontend navigation is changed from browser router to hash based router, as somehow navigation breaks in the custom scheme, as the frontend tries to actually request the individual pages from QtWebEngine. Not sure why it was working before or what causes it, but a local hash based router seems to work.

In d78380f, we switched from qrc:/ to the bitboxapp:/ custom scheme
so we can force mimetypes in the scheme handler. This somehow made
window.isSecureContext be false, breaking camera (which requires a
secure context).

The issue was that our scheme handler was never registered, because it
was configued with HostAndPort but no default port was specified. We
could specify one, or switch to Host only, but in our case Path seems
to be most appropriate.

The frontend navigation is changed from browser router to hash based
router, as somehow navigation breaks in the custom scheme, as the
frontend tries to actually request the individual pages from
QtWebEngine. Not sure why it was working before or what causes it, but
a local hash based router seems to work.
Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested LGTM

const currentURL = window.location.pathname;
const isIndex = currentURL === '/' || currentURL === '/index.html' || currentURL === '/android_asset/web/index.html' || currentURL.endsWith('/assets/web/index.html');
const currentURL = window.location.hash.replace(/^#/, '');
const isIndex = currentURL === '' || currentURL === '/';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@benma benma merged commit 58498b2 into BitBoxSwiss:release-v4.46.3 Nov 26, 2024
7 checks passed
Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK on linux and Android 11

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.

3 participants