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 winit 0.29 #3606

Closed
wants to merge 8 commits into from
Closed

Update to winit 0.29 #3606

wants to merge 8 commits into from

Conversation

fornwall
Copy link
Contributor

@fornwall fornwall commented Nov 21, 2023

This is a start for updating to winit 0.29.

A lot of things patched out, broken and not tested, but at least the egui_demo_app starts with both glow and wgpu, as well as pure_glow (but are not functional).

Review feedback and patches to fill out missing features and fix issues are welcome!

Replaces #3496 (closed that by mistake and couldn't reopen).

"ndk-sys 0.5.0+25.2.9519653",
"num_enum 0.7.1",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to disable default features on the ndk to get rid of this.

(If there's no direct ndk dependency, this will happen with the next winit 0.29.4 release - we forgot it in the update)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no direct ndk dependency, I guess we can await winit 0.29.4.

@@ -2620,10 +2703,10 @@ checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
dependencies = [
"libc",
"log",
"ndk",
"ndk 0.7.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff-context suggests that this is ndk-glue, which is long gone and replaced with android-activity. Stale dependency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in ndarilek/tts-rs#50.

}
EventResult::Wait
}

Copy link
Contributor Author

@fornwall fornwall Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove this, as winit::event::Event::Resumed is handled above.

Let's make sure to test on Android - there is a eframe using example in android-activity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're working on glow_integration, it's probably wise to remove this stale comment entirely:

// Note: that the current Glutin API design tightly couples the GL context with
// the Window which means it's not practically possible to just destroy the
// window and re-create a new window while continuing to use the same GL context.
//
// For now this means it's not possible to support Android as well as we can with
// wgpu because we're basically forced to destroy and recreate _everything_ when
// the application suspends and resumes.
//
// There is work in progress to improve the Glutin API so it has a separate Surface
// API that would allow us to just destroy a Window/Surface when suspending, see:
// https://github.com/rust-windowing/glutin/pull/1435

The issue linked there has long been closed and fixed. Windows/Surfaces are only associated with context when/while it's made current, and it looks like eframe supports Android now with a proper Resumed/Suspended cycle?

repaint_asap = true;
glutin.resize(viewport_id, **new_inner_size);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In winit 0.29 ScaleFactorChanged does not expose the new OS suggested window size. But, a Resized event will come (recently fixed on macOS - rust-windowing/winit#3214).

@@ -39,7 +39,7 @@ fn create_event_loop(native_options: &mut epi::NativeOptions) -> EventLoop<UserE
let mut builder = create_event_loop_builder(native_options);

crate::profile_scope!("EventLoopBuilder::build");
builder.build()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add error handling.

@@ -160,7 +162,7 @@ fn run_and_return(
EventResult::Exit => {
log::debug!("Asking to exit event loop…");
winit_app.save_and_destroy();
*control_flow = ControlFlow::Exit;
event_loop_window_target.exit();
Copy link
Contributor Author

@fornwall fornwall Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this winit_app.save_and_destroy() - we are going to get a Event::LoopExiting event later?

@@ -132,7 +134,7 @@ fn run_and_return(

match event_result {
EventResult::Wait => {
control_flow.set_wait();
event_loop_window_target.set_control_flow(ControlFlow::Wait);
}
EventResult::RepaintNow(window_id) => {
log::trace!("Repaint caused by {}", short_event_description(&event));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cane some of this be simplified or removed for winit 0.29?

@fornwall fornwall changed the title WIP: Update to winit 0.29 Update to winit 0.29 Nov 22, 2023
@emilk emilk added eframe Relates to epi and eframe egui-winit porblems related to winit dependencies Pull requests that update a dependency file labels Nov 27, 2023
crates/egui-winit/Cargo.toml Outdated Show resolved Hide resolved
crates/egui-winit/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for working on this ❤️

crates/egui_glow/examples/pure_glow.rs Show resolved Hide resolved
@gerwin3
Copy link

gerwin3 commented Nov 27, 2023

I think this PR also fixes #3415 because the winit key representation changed :)

@emilk
Copy link
Owner

emilk commented Nov 27, 2023

Btw, creating a PR from your master branch is a pretty bad idea for a couple of resons:

  • It means commits added by me are pushed directly to your master
  • It creates an annoying branch name-clash for other contributors

…that's why the egui PR template suggest you don't do it ;)

In fact, I'm having trouble adding new commits to this PR now, for some obscure git reason

@fornwall fornwall deleted the branch emilk:master November 27, 2023 21:44
@fornwall fornwall closed this Nov 27, 2023
@fornwall fornwall deleted the master branch November 27, 2023 21:45
@fornwall fornwall mentioned this pull request Nov 27, 2023
@fornwall
Copy link
Contributor Author

fornwall commented Nov 27, 2023

@emilk Really sorry about that, was just a mistake to create from a master branch.

Replaced with #3649 to create from a winit-0.29 branch - does that work better?

@fornwall fornwall mentioned this pull request Nov 27, 2023
@emilk
Copy link
Owner

emilk commented Nov 28, 2023

Thanks @fornwall - I can push commits to the new branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file eframe Relates to epi and eframe egui-winit porblems related to winit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to winit 0.29
4 participants