`AppLifecycleListener` `onHide` and `onInactive` firing at wrong time on iOS · Issue #146734 · flutter/flutter · GitHub
Skip to content

AppLifecycleListener onHide and onInactive firing at wrong time on iOS #146734

Open

Description

@mgenware

Steps to reproduce

  1. Clone this example repo: https://github.com/mgenware/resign_active_issue
  2. Since we need to view native (swift) logs, please run the project in xcode
  3. cd ios
  4. pod install
  5. open and run project in xcode
  6. click the "push view controller" button, which presents a UIDocumentInteractionController
  7. xcode shows the following logs
flutter: Flutter inactive
flutter: Flutter hiding

The demo also has logs in native applicationWillResignActive:

    override func applicationWillResignActive(_ application: UIApplication) {
        print("Native resignActive")
    }

When you pressed the home button, the native applicationWillResignActive gets called.

Expected results

inactive/hide events should not fire when the app is still in foreground.

inactive/hide events should fire when home button is pressed.

the native applicationWillResignActive gets called when home button is pressed.

Actual results

❌ inactive/hide events fired when a new view controller is pushed while the app is still in foreground.

❌ inactive/hide events didn't fire when home button is pressed.

✅ the native applicationWillResignActive gets called when home button is pressed.

Code sample

See repro steps

Screenshots or Video

Screenshots / Video demonstration

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-CN)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.88.1)
[✓] Connected device (3 available)
[✓] Network resources

Activity

  1. danagbemava-nc commented on Apr 15, 2024

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.19.5 on channel stable at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
        • Engine revision e76c956498
        • Dart version 3.3.3
        • DevTools version 2.31.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.1)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.87.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.86.0
    
    [✓] Connected device (5 available)
        • Pixel 7 (mobile)     • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 14 (API 34)
        • Nexus (mobile)       • 00008020-001875E83A38002E                        • ios            • iOS 17.4.1 21E236
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E                        • ios            • iOS 17.4.1 21E236
        • macOS (desktop)      • macos                                            • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)         • chrome                                           • web-javascript • Google Chrome 123.0.6312.123
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
    [!] Flutter (Channel master, 3.22.0-10.0.pre, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.0-10.0.pre on channel master at /Users/nexus/dev/sdks/flutters
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 1002ce4b03 (18 hours ago), 2024-04-14 20:29:43 +0530
        • Engine revision 1a13c7d1f4
        • Dart version 3.5.0 (build 3.5.0-47.0.dev)
        • DevTools version 2.34.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2023.1)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.87.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.86.0
    
    [✓] Connected device (6 available)
        • Pixel 7 (mobile)                • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 14 (API 34)
        • Nexus (mobile)                  • 00008020-001875E83A38002E                        • ios            • iOS 17.4.1 21E236
        • Dean’s iPad (mobile)            • 00008103-000825C811E3401E                        • ios            • iOS 17.4.1 21E236
        • macOS (desktop)                 • macos                                            • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                            • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                                           • web-javascript • Google Chrome 123.0.6312.123
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  2. added
    platform-iosiOS applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-iosOwned by iOS platform team
    and removed
    in triagePresently being triaged by the triage team
    on Apr 15, 2024
  3. LouiseHsu commented on Apr 24, 2024

    @LouiseHsu
    Contributor

    @gspencergoog I heard you worked on this last year, do you think you can take a look to see if this is still an issue?

  4. added
    P2Important issues not at the top of the work list
    triaged-iosTriaged by iOS platform team
    on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions