Implement Send for Context on WASM on `wasm32-unknown-unknown`
Author: wensimehrpCreated Sep 2, 2026Updated Sep 10, 2026
(Originally posted on https://discord.com/channels/900275882684477440/904461220592119849/1544363014113853741)
`hashbrown::raw::RawTable<(ViewportId, egui::context::ViewportState)>` cannot be sent between threads safely
within `egui::context::ContextImpl`, the trait `Send` is not implemented for `hashbrown::raw::RawTable<(ViewportId, egui::context::ViewportState)>`
required for `lock_api::rwlock::RwLock<parking_lot::raw_rwlock::RawRwLock, egui::context::ContextImpl>` to implement `Sync`
required for `Arc<egui::mutex::RwLock<egui::context::ContextImpl>>` to implement `Send`
the full name for the type has been written to '/home/jeremyg/Code/Paiagram/target/wasm32-unknown-unknown/debug/build/paiagram/3dd480a25331672d/out/paiagram-3dd480a25331672d.long-type-15969912598606154758.txt'
consider using `--verbose` to print the full type name to the consolefn load_file(
dialog: AsyncFileDialog,
import_type: ImportType,
state: Arc<Mutex<FileLoadState>>,
ctx: Context,
) {
*state.lock().unwrap() = FileLoadState::Reading { progress: None };
let process = async move {
let data = dialog.pick_file().await;
let Some(data) = data else {
*state.lock().unwrap() = FileLoadState::Idle;
return;
};
*state.lock().unwrap() = FileLoadState::Processing { progress: None };
let data = data.read().await;
rayon::spawn(move || {
let commands = generate_commands(&data, import_type).map_err(|e| e.to_string());
*state.lock().unwrap() = FileLoadState::Done(commands);
ctx.request_repaint();
});
};
#[cfg(target_arch = "wasm32")]
{
wasm_bindgen_futures::spawn_local(process);
}
#[cfg(not(target_arch = "wasm32"))]
{
let _ = std::thread::spawn(move || pollster::block_on(process));
}
}I got this error that basically says I can't send Context to another thread in wasm32-unknown-unknown. I thought it would implement send in this case. In this case I can fix it by using futures_channel and awaiting the thread in the async block, but I want to know why Context doesn't impl Send.
Source: emilk/egui