winit-web: return immediately from run_app on web
This avoids using JavaScript exceptions to support `EventLoop::run_app` on the web, which is a huge hack, and doesn't work with the Exception Handling Proposal for WebAssembly: https://github.com/WebAssembly/exception-handling This needs the application handler passed to `run_app` to be `'static`, but that works better on iOS too anyhow (since you can't accidentally forget to pass in state that then wouldn't be dropped when terminating).
This commit is contained in:
parent
e8bccfff4f
commit
f69b601abb
9 changed files with 81 additions and 102 deletions
|
|
@ -238,7 +238,8 @@ impl EventLoop {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn run_app<A: ApplicationHandler>(self, app: A) -> ! {
|
||||
// Require `'static` for correctness, we won't be able to `Drop` the user's state otherwise.
|
||||
pub fn run_app<A: ApplicationHandler + 'static>(self, app: A) -> ! {
|
||||
let application: Option<Retained<UIApplication>> =
|
||||
unsafe { msg_send![UIApplication::class(), sharedApplication] };
|
||||
assert!(
|
||||
|
|
@ -250,6 +251,10 @@ impl EventLoop {
|
|||
|
||||
// We intentionally override neither the application nor the delegate,
|
||||
// to allow the user to do so themselves!
|
||||
//
|
||||
// NOTE: `UIApplicationMain` is _the only way_ to start the event loop on iOS/UIKit, there
|
||||
// are no other feasible options. See also:
|
||||
// <https://github.com/rust-windowing/winit/pull/4165#issuecomment-2760514167>
|
||||
app_state::launch(self.mtm, app, || UIApplication::main(None, None, self.mtm))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue