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

Clipboard access on non https site breaks app #5388

Closed
e00E opened this issue Nov 20, 2024 · 1 comment
Closed

Clipboard access on non https site breaks app #5388

e00E opened this issue Nov 20, 2024 · 1 comment
Labels
bug Something is broken

Comments

@e00E
Copy link
Contributor

e00E commented Nov 20, 2024

This issue is out of egui's control. I'm creating it to help other people running into it when they search for the error message.

Description

When you try to use the clipboard in egui web app for example by selecting text and pressing ctrl-c to copy it, then you get an error in the console and the whole app freezes forever. This only happens if you access the site over http instead of https. On localhost like through trunk serve it does not happen either.

In Firefox the error starts with this line:

Uncaught TypeError: getObject(...) is undefined

In Chrome the error starts with this line:

Uncaught TypeError: Cannot read properties of undefined (reading 'writeText')

Explanation

Egui since version.0.29.0 supports clipboard access on the web. In egui code this happens through window.navigator().clipboard(). As the MDN page warns:

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

This is not reflected in this web-sys API, which causes a panic when the API is not available like in this case. The issue has been reported here rustwasm/wasm-bindgen#4085 .

@e00E e00E added the bug Something is broken label Nov 20, 2024
@lucasmerlin
Copy link
Collaborator

There already is #5293 and a PR #5326 for this, so I'm closing this as a duplicate. This should be "fixed" in the next egui release (we will log a helpful error message and added a note to the docs).

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

No branches or pull requests

2 participants