Investigate and submit fix for winit iOS event loop ordering bug #3

Open
opened 2025-12-15 22:31:29 +00:00 by siennathesane · 0 comments
siennathesane commented 2025-12-15 22:31:29 +00:00 (Migrated from github.com)

Problem

The app currently logs excessive warnings on iOS:

processing non `RedrawRequested` event after the main event loop: AboutToWait

This is a known bug in winit's iOS/UIKit backend.

Upstream Issue

  • rust-windowing/winit#3714
  • Status: Open since May 2024
  • Root cause: "application state tracking is broken on newer iOS versions" per winit maintainers
  • The UIKit backend is outdated and hasn't been updated in a long time

Impact

  • Functional: Harmless - app renders and works correctly
  • Developer Experience: Severe - logs are spammed every frame, making debugging impossible
  • Performance: Unknown - upstream report mentions "sporadic but very noticeable slowdowns"

Current Workaround

Suppress the warning by filtering winit error logs:

.add_directive("winit=warn".parse().unwrap())

Investigation Plan

  1. Understand winit's iOS backend architecture

    • Read winit's iOS/UIKit backend code
    • Understand how event loop phases work on iOS
    • Review ApplicationHandler trait and event ordering expectations
  2. Reproduce and isolate

    • Create minimal winit-only example (no Bevy) to reproduce
    • Verify the issue occurs with vanilla winit
    • Test on different iOS versions/devices
  3. Identify root cause

    • Trace where AboutToWait events are being dispatched
    • Determine why they're being processed after RedrawRequested
    • Check iOS UIApplicationMain/UIKit run loop integration
  4. Develop fix

    • Implement proper event ordering in iOS backend
    • Ensure fix doesn't break existing winit guarantees
    • Test with various winit examples
  5. Submit upstream

    • Create PR to rust-windowing/winit
    • Work with maintainers on review/feedback
    • Get merged into next winit release
  6. Update our code

    • Once fixed in winit, update our dependency
    • Remove the workaround filter
    • Verify logs are clean

Resources

Success Criteria

  • Minimal reproduction case created
  • Root cause identified and documented
  • Fix implemented and tested
  • PR submitted to winit
  • PR merged upstream
  • Our app updated to use fixed winit version
  • Logs are clean on iOS without warning suppression
## Problem The app currently logs excessive warnings on iOS: ``` processing non `RedrawRequested` event after the main event loop: AboutToWait ``` This is a known bug in winit's iOS/UIKit backend. ## Upstream Issue - [rust-windowing/winit#3714](https://github.com/rust-windowing/winit/issues/3714) - Status: Open since May 2024 - Root cause: "application state tracking is broken on newer iOS versions" per winit maintainers - The UIKit backend is outdated and hasn't been updated in a long time ## Related - [bevyengine/bevy#12934](https://github.com/bevyengine/bevy/discussions/12934) - Multiple Bevy users experiencing same issue ## Impact - **Functional**: Harmless - app renders and works correctly - **Developer Experience**: Severe - logs are spammed every frame, making debugging impossible - **Performance**: Unknown - upstream report mentions "sporadic but very noticeable slowdowns" ## Current Workaround Suppress the warning by filtering winit error logs: ```rust .add_directive("winit=warn".parse().unwrap()) ``` ## Investigation Plan 1. **Understand winit's iOS backend architecture** - Read winit's iOS/UIKit backend code - Understand how event loop phases work on iOS - Review ApplicationHandler trait and event ordering expectations 2. **Reproduce and isolate** - Create minimal winit-only example (no Bevy) to reproduce - Verify the issue occurs with vanilla winit - Test on different iOS versions/devices 3. **Identify root cause** - Trace where AboutToWait events are being dispatched - Determine why they're being processed after RedrawRequested - Check iOS UIApplicationMain/UIKit run loop integration 4. **Develop fix** - Implement proper event ordering in iOS backend - Ensure fix doesn't break existing winit guarantees - Test with various winit examples 5. **Submit upstream** - Create PR to rust-windowing/winit - Work with maintainers on review/feedback - Get merged into next winit release 6. **Update our code** - Once fixed in winit, update our dependency - Remove the workaround filter - Verify logs are clean ## Resources - [winit iOS backend source](https://github.com/rust-windowing/winit/tree/master/src/platform_impl/ios) - [ApplicationHandler documentation](https://docs.rs/winit/latest/winit/application/trait.ApplicationHandler.html) - [Apple UIKit Run Loop docs](https://developer.apple.com/documentation/uikit) ## Success Criteria - [ ] Minimal reproduction case created - [ ] Root cause identified and documented - [ ] Fix implemented and tested - [ ] PR submitted to winit - [ ] PR merged upstream - [ ] Our app updated to use fixed winit version - [ ] Logs are clean on iOS without warning suppression
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: studio/marathon#3