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

Copy doesn't work on Safari #3480

Closed
abey79 opened this issue Oct 17, 2023 · 1 comment · Fixed by #3513
Closed

Copy doesn't work on Safari #3480

abey79 opened this issue Oct 17, 2023 · 1 comment · Fixed by #3513
Labels
bug Something is broken eframe Relates to epi and eframe rerun Desired for Rerun.io web Related to running Egui on the web
Milestone

Comments

@abey79
Copy link
Collaborator

abey79 commented Oct 17, 2023

Describe the bug

Copying text from https://egui.rs (e.g. from the text edit widget) or indeed Rerun web doesn't work on Safari. This is particularly annoying for Rerun's new Quick Start guide's code block, which are meant to be copied by the user.

To Reproduce

  1. Go to https://egui.rs -> Widget Gallery
  2. Enter text in the TextEdit widget
  3. Select and copy that text

=> beeps and generate the following error in the console:

ERROR: [eframe::web] eframe/src/web/mod.rs:199: Copy/cut action failed: JsValue(NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
writeText@[native code]
@https://www.egui.rs/egui_demo_app.js:941:46
<?>.wasm-function[644]@[wasm code]
<?>.wasm-function[516]@[wasm code]
<?>.wasm-function[2521]@[wasm code]
__wbg_adapter_30@https://www.egui.rs/egui_demo_app.js:226:136
real@https://www.egui.rs/egui_demo_app.js:209:21)

Desktop (please complete the following information):

  • OS: macOS Sonoma 14.0
  • Browser: Safari 17.0

Related to:

@abey79 abey79 added bug Something is broken web Related to running Egui on the web eframe Relates to epi and eframe labels Oct 17, 2023
Wumpf pushed a commit to rerun-io/rerun that referenced this issue Oct 17, 2023
### What

Gives us copy button in code blocks:

<img width="1190" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/b6c30e4c-9e0b-4312-a908-652cc6d424e2">

Note: copy/paste seems to not work from web/Safari
emilk/egui#3480.


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3882) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/3882)
- [Docs
preview](https://rerun.io/preview/79bc94fd4e913f5f2c6eb185c08089f2d2d654ee/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/79bc94fd4e913f5f2c6eb185c08089f2d2d654ee/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
abey79 added a commit to rerun-io/rerun that referenced this issue Oct 17, 2023
…lipboard (#3898)

### What

For security reason, Safari doesn't let use copy text from our Web
viewer, see:
- emilk/egui#3480

This PR detects if we are running on Safari and adds a warning to the
top of the Quick Start guides.

<img width="1112" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/a8bf5a1c-5c64-42ef-942e-344bc100015a">


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3898) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/3898)
- [Docs
preview](https://rerun.io/preview/063e12defa92f5249e22c771c4fe0454231420cc/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/063e12defa92f5249e22c771c4fe0454231420cc/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
@lunixbochs
Copy link
Contributor

Triaging this issue, looking to fix it.

  1. Copy hits this event listener (and cut the one above it): https://github.com/emilk/egui/blob/0.23.0/crates/eframe/src/web/events.rs#L184
  2. repaint_asap is indirect. It just updates NeedsRepaint. This means the "copy" and "cut" document event handlers return without egui actually touching the clipboard. https://github.com/emilk/egui/blob/0.23.0/crates/eframe/src/web/backend.rs#L72
  3. Safari probably wants you to access the clipboard during the copy event, in direct response to user input. Instead the clipboard write probably comes from the next rendering tick. This is blocked by security policy.

Here's a better traceback:

ERROR: [eframe::web] eframe/src/web/mod.rs:200: Copy/cut action failed: JsValue(NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
writeText@[native code]
@http://127.0.0.1:8080/project-5a43784c0edafe62.js:793:46
<?>.wasm-function[web_sys::features::gen_Clipboard::Clipboard::write_text::h3336955eaeb60a58]@[wasm code]
<?>.wasm-function[eframe::web::set_clipboard_text::he6e87b49ba08fe1b]@[wasm code]
<?>.wasm-function[eframe::web::app_runner::AppRunner::logic::hcf05f7e86b369dbf]@[wasm code]
<?>.wasm-function[eframe::web::events::paint_and_schedule::h38124beb8785c431]@[wasm code]
<?>.wasm-function[<T as wasm_bindgen::closure::WasmClosureFnOnce<(),R>>::into_fn_mut::{{closure}}::hfd84448ff0d2d845]@[wasm code]
<?>.wasm-function[<dyn core::ops::function::FnMut<()>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h1d4dabdf8919906c]@[wasm code]
__wbg_adapter_27@http://127.0.0.1:8080/project-5a43784c0edafe62.js:223:136
real@http://127.0.0.1:8080/project-5a43784c0edafe62.js:202:21)

lunixbochs added a commit to talonvoice/egui that referenced this issue Oct 30, 2023
lunixbochs added a commit to talonvoice/egui that referenced this issue Oct 30, 2023
@emilk emilk added this to the 0.24.0 milestone Nov 7, 2023
@emilk emilk added the rerun Desired for Rerun.io label Nov 7, 2023
emilk pushed a commit that referenced this issue Nov 21, 2023
* Closes <#3480>

I've tested this on Safari and Chrome on macOS Sonoma 14.0.

Could be improved to only call `event.preventDefault()` if
`runner.logic()` actually performed a copy, but I don't see a way to get
that information out with the current API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken eframe Relates to epi and eframe rerun Desired for Rerun.io web Related to running Egui on the web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants