linebender/druid

Web example crashes when using clipboard in wasm

Open

#2321 opened on Jan 4, 2023

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Rust (9,091 stars) (567 forks)batch import
bughelp wantedshell/web

Description

It looks like Druid tries to call Application::global() when doing stuff with the clipboard but this panics, maybe because the global app is stored in a thread_local! variable which doesn't work in wasm.

Steps to reproduce

  1. Clone the repo and then run:
❯ wasm-pack build --target web --dev
❯ http
  1. Open browser and navigate to http://localhost:8000/
  2. Try to cut/copy/paste any text in the textbox
  3. See the following error in the JS console:
hello_web.js:333 panicked at 'There is no globally active Application', /.../druid/druid-shell/src/application.rs:109:35

Stack:

Error
    at http://localhost:8000/pkg/hello_web.js:339:21
    at logError (http://localhost:8000/pkg/hello_web.js:233:18)
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:8000/pkg/hello_web.js:338:66)
    at console_error_panic_hook::Error::new::h196751a1eab8f86e (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[8917]:0x31a10f)
    at console_error_panic_hook::hook_impl::h0db4adfa38059141 (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[1669]:0x201334)
    at console_error_panic_hook::hook::hd8a36f6179709228 (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[9547]:0x322b08)
    at core::ops::function::Fn::call::hf4cc558cb113cf3a (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[8654]:0x315f70)
    at std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[3489]:0x280df4)
    at std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[4587]:0x2b35fc)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc (http://localhost:8000/pkg/hello_web_bg.wasm:wasm-function[10070]:0x3295f0)

Contributor guide