Skip to content

[bug] iOS: Inconsistent generation of Event::Suspended and Event::Resumed #1307

Description

@alexmoon

Describe the bug

#1146 in v0.35.0 changed the generation of Event::Resumed from applicationDidBecomeActive to applicationWillEnterForeground. Unfortunately these events are not synonymous and can lead to situations where an app gets stuck in the Suspended state.

Steps To Reproduce

  1. While your iOS app is in the foreground, open the iOS control center or app switcher. applicationWillResignActive is received which generates Event::Suspended as expected.

  2. Close the control center or app switcher to return to your app. applicationWillEnterForeground is never called because the app remained in the foreground while it was inactive. Therefore Event::Resumed is never generated which leaves the app thinking it is in the Suspended state while it is actually active.

Expected behavior

Event::Resumed and Event::Suspended should be generated symmetrically. I think that #1146 should be reverted and the previous behavior where the Resumed/Suspended state track the "active" state of the app be restored.

Alternately, if there is a strong desire for the Resumed/Suspended state to track the foreground state of the app instead, then Event::Suspended should only be generated from applicationDidEnterBackground not applicationWillResignActive and other events need to be generated for the "active" state (possibly WindowEvent::Focus, but I'm not sure it makes sense to generate that for an application-level event).

I'm happy to provide a PR for the desired solution.

Platform and Versions (please complete the following information):
OS: iOS
Rustc: 1.97.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions