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

Update to egui/eframe 0.20.0 #83

Merged
merged 7 commits into from
Dec 8, 2022
Merged

Update to egui/eframe 0.20.0 #83

merged 7 commits into from
Dec 8, 2022

Conversation

Wumpf
Copy link
Collaborator

@Wumpf Wumpf commented Dec 5, 2022

had to run cargo update to resolve a dependency issue when building with wgpu, keeping those changes here

@Wumpf Wumpf marked this pull request as draft December 5, 2022 15:49
@Wumpf
Copy link
Collaborator Author

Wumpf commented Dec 5, 2022

this only works with trunk egui ofc

src/main.rs Outdated Show resolved Hide resolved
@coderedart
Copy link
Contributor

one solution is adding wasm-bindgen-futures as dependency.

then just renaming current main fn to fake_main

// this is the new main. use wasm_biindgen_futures to spawn it
#[cfg(target_arch = "wasm32")]
fn main() {
    wasm_bindgen_futures::spawn_local(fake_main());
}
// this is the previous main fn. just add async to it
#[cfg(target_arch = "wasm32")]
pub async fn fake_main() {
}

@coderedart
Copy link
Contributor

In etk crate, i personally just used pollster::block_on as nobody actually runs a game (or any rendering) in async mode.
https://github.com/coderedart/etk/blob/master/crates/egui_backend/src/gfx_backends/wgpu_backend.rs#L106

this will avoid async polluting all the parent functions too (was necessary in etk because GfxBackend trait abstracted over all gfx api backends like opengl + vk etc.. ).

@Wumpf
Copy link
Collaborator Author

Wumpf commented Dec 5, 2022

pollster::block_on breaks down when using WebGPU as a backend as this actually needs to hand back to the browser during device creation.

@emilk
Copy link
Owner

emilk commented Dec 5, 2022

@coderedart btw, trunk serve recompiles all dependencies when changing anything in main.rs. This is… very annoying

@emilk
Copy link
Owner

emilk commented Dec 5, 2022

wasm_bindgen_futures::spawn_local works well, and seems less hacky!

@coderedart
Copy link
Contributor

coderedart commented Dec 5, 2022

pollster::block_on breaks down when using WebGPU as a backend as this actually needs to hand back to the browser during device creation.

ooh, good to know. thanks. I completely forgot that webgpu is a thing.

@coderedart btw, trunk serve recompiles all dependencies when changing anything in main.rs. This is… very annoying

I am relieved that its not just me. I just assumed it was rust-analyzer noise because when i pass --release flag, it doesn't recompile deps, but without the flag, it will recompile some dependencies. I will dig deeper today

@coderedart
Copy link
Contributor

@emilk yeah, its rust analyzer clashing with cargo. even without trunk, after a change, running cargo build --target=wasm32-unknown-unknown will trigger full recompilation. if i just edit using vim without RA, then the dependencies are not recompiled.

@emilk emilk changed the title Fix issues with eframe::start_web becoming async Update to egui/eframe 0.20.0 Dec 8, 2022
@emilk emilk marked this pull request as ready for review December 8, 2022 14:27
@emilk emilk merged commit 0d7b06b into master Dec 8, 2022
@emilk emilk deleted the fix-web-build branch August 23, 2023 14:46
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