Repository: flutter
Issue: [Android] Dart timers unresponsive after coming from background
Labels: e: device-specific,platform-android,P2,team-android,triaged-android

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->
Hello, I've encountered with this issue when the battery optimization setting on a One Plus 8T (Android 11) is active. This setting is active by default on the One Plus's and Xiaomis. I haven't been able to reproduce it in other devices. It may be possible to reproduce it as well on Android 12.

The issue appears when having a periodic timer, for instance every 20s and a simple timer that could be used under the hood in many places of the app, like a debounced search input. When the app goes to the background, the periodic timer will stop emitting event after about 1.5-2 minutes. Then, when the app goes to foreground, if we interact with the simple timer, it will be unresponsive, and will emit after several seconds (15-30s), even when configured to run in under a second.  

One way to stop this issue from occurring is by "triggering" an empty Future after the app comes to the foreground.
```dart
@override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    print("AppLifecycleState changed: $state");
    if (state == AppLifecycleState.resumed) {
      print("Application resumed. ${DateTime.now()}");

      // If we include this, it's like the Timers come back alive
      
      Future(() => null).then((value) {
        print("Finish some future ${DateTime.now()}");
      });
    }
  }
```

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Make sure that Battery optimization is active for the demo app
2. Run the app
3. Tap the button, after a small delay, a snackbar will appear
4. Switch to a different app and wait for about 2 minutes.
5. Go back to the Flutter application
6. Tap again the button and this time the snackbar will not appear until several seconds later.

**Expected results:** <!-- what did you want to see? -->
The "debounced" timer should work after going to the foreground

**Actual results:** <!-- what did you see? -->
The timer is unresponsive

## Simplified logs of the execution

```
START THE APP
[  +25 ms] I/flutter (24881): Periodic callback 2021-11-23 09:55:24.092078
[ +438 ms] I/flutter (24881): On pressed 2021-11-23 09:55:27.506217
[+1038 ms] I/flutter (24881): Delayed! 2021-11-23 09:55:28.010871

GO TO BACKGROUND
[ +826 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.inactive
[ +135 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.paused
[+13205 ms] I/flutter (24881): Periodic callback 2021-11-23 09:55:44.135751
[+19735 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:04.122471
[+19998 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:24.103399
[+19975 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:44.096007

AFTER 2 MINUTES, GO FOREGROUND (Notice that a periodic callback has been missed, because of battery optimizations)
[+2175 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.resumed
[   +3 ms] I/flutter (24881): Application resumed. 2021-11-23 09:57:35.921718
[ +825 ms] I/flutter (24881): On pressed 2021-11-23 09:57:36.782580

AFTER TAPPING THE BUTTON: The periodic callback and debounced timer resolve at the same time. But the debounced timer should have resolved 20 seconds earlier.
[+16964 ms] I/flutter (24881): Periodic callback 2021-11-23 09:57:53.748283
[ ] I/flutter (24881): Delayed! 2021-11-23 09:57:53.748653
```

<details>
<summary>Code sample</summary>

```dart
import 'dart:async';

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
  Timer? buttonDebounceTimer;

  late final Timer periodicTimer;

  @override
  void initState() {
    super.initState();

    periodicTimer = Timer.periodic(const Duration(seconds: 20), (_) async {
      await doWork();
    });
    doWork();

    WidgetsBinding.instance!.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance!.removeObserver(this);

    buttonDebounceTimer?.cancel();
    periodicTimer.cancel();
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    print("AppLifecycleState changed: $state");
    if (state == AppLifecycleState.resumed) {
      print("Application resumed. ${DateTime.now()}");

      // If we include this, it's like the Timers come back alive
      
      // Future(() => null).then((value) {
      //   print("Finish some future ${DateTime.now()}");
      // });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Dart Timer issue"),
      ),
      body: Center(
          child: ElevatedButton(
        onPressed: () {
          print("On pressed ${DateTime.now()}");

          // This timer acts like a small debounce
          buttonDebounceTimer?.cancel();
          buttonDebounceTimer = Timer(const Duration(milliseconds: 500), () {
            print("Delayed! ${DateTime.now()}");

            ScaffoldMessenger.of(context).removeCurrentSnackBar();
            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content: Text("Debounced snackbar ${DateTime.now()}!")),
            );
          });
        },
        child: const Text("TAP ME"),
      )),
    );
  }

  Future<void> doWork() async {
    print("Periodic callback ${DateTime.now()}");
  }
}

```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
➜ flutter run --verbose
[  +37 ms] executing: uname -m
[  +16 ms] Exit code 0 from: uname -m
[        ] x86_64
[   +3 ms] executing: [/home/david/fvm/versions/stable/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +2 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 18116933e77adc82f80866c928266a5b4f1ed645
[        ] executing: [/home/david/fvm/versions/stable/] git tag --points-at 18116933e77adc82f80866c928266a5b4f1ed645
[   +6 ms] Exit code 0 from: git tag --points-at 18116933e77adc82f80866c928266a5b4f1ed645
[        ] 2.5.3
[   +5 ms] executing: [/home/david/fvm/versions/stable/] git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/home/david/fvm/versions/stable/] git ls-remote --get-url origin
[   +1 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +55 ms] executing: [/home/david/fvm/versions/stable/] git rev-parse --abbrev-ref HEAD
[   +2 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +32 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +33 ms] executing: /home/david/Android/Sdk/platform-tools/adb devices -l
[  +19 ms] List of devices attached
           ac268173               device usb:2-3 product:OnePlus8T model:KB2003 device:OnePlus8T transport_id:3
[   +3 ms] /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell getprop
[  +24 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +41 ms] Skipping pub get: version match.
[  +62 ms] Generating /home/david/Dev/Flutter/timer_issue/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +37 ms] ro.hardware = qcom
[  +19 ms] Initializing file store
[   +7 ms] Skipping target: gen_localizations
[   +3 ms] Skipping target: gen_dart_plugin_registrant
[        ] Skipping target: _composite
[   +1 ms] complete
[   +3 ms] Launching lib/main.dart on KB2003 in debug mode...
[   +4 ms] /home/david/fvm/versions/stable/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/david/fvm/versions/stable/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/home/david/fvm/versions/stable/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true
--output-dill /tmp/flutter_tools.MIDRET/flutter_tool.TUOITT/app.dill --packages /home/david/Dev/Flutter/timer_issue/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts
--track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill build/c075001b96339384a97db4862b8ab8db.cache.dill.track.dill --enable-experiment=alternative-invalidation-strategy
[   +7 ms] executing: /home/david/Android/Sdk/build-tools/31.0.0/aapt dump xmltree /home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[  +19 ms] Exit code 0 from: /home/david/Android/Sdk/build-tools/31.0.0/aapt dump xmltree /home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1e
               A: android:compileSdkVersionCodename(0x01010573)="11" (Raw: "11")
               A: package="com.example.timer_issue" (Raw: "com.example.timer_issue")
               A: platformBuildVersionCode=(type 0x10)0x1e
               A: platformBuildVersionName=(type 0x10)0xb
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1e
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=16)
                 A: android:label(0x01010001)="timer_issue" (Raw: "timer_issue")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=21)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.timer_issue.MainActivity" (Raw: "com.example.timer_issue.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=35)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=45)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=49)
                     E: action (line=50)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=52)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=59)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +4 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell -x logcat -v time -t 1
[   +6 ms] <- compile package:timer_issue/main.dart
[ +228 ms] --------- beginning of main
                    11-23 09:55:02.011 W/SDM     (  979): QoSImpl::GetReadAB: Pipe Bandwidth without compression: 5161.708 Exceeded the bandwidth limit: 4400.000
[   +5 ms] executing: /home/david/Android/Sdk/platform-tools/adb version
[   +2 ms] Android Debug Bridge version 1.0.41
           Version 31.0.3-7562133
           Installed as /home/david/Android/Sdk/platform-tools/adb
[   +1 ms] executing: /home/david/Android/Sdk/platform-tools/adb start-server
[   +4 ms] Building APK
[  +12 ms] Running Gradle task 'assembleDebug'...
[   +2 ms] Using gradle from /home/david/Dev/Flutter/timer_issue/android/gradlew.
[  +11 ms] executing: /home/david/opt/android-studio/jre/bin/java -version
[ +163 ms] Exit code 0 from: /home/david/opt/android-studio/jre/bin/java -version
[        ] openjdk version "11.0.10" 2021-01-19
           OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
           OpenJDK 64-Bit Server VM (build 11.0.10+0-b96-7249189, mixed mode)
[   +1 ms] executing: [/home/david/Dev/Flutter/timer_issue/android/] /home/david/Dev/Flutter/timer_issue/android/gradlew -Pverbose=true -Ptarget-platform=android-arm64
-Ptarget=/home/david/Dev/Flutter/timer_issue/lib/main.dart -Pdart-defines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== -Pdart-obfuscation=false -Ptrack-widget-creation=true -Ptree-shake-icons=false
-Pfilesystem-scheme=org-dartlang-root assembleDebug
[ +680 ms] Starting a Gradle Daemon (subsequent builds will be faster)
[+6598 ms] > Task :app:compileFlutterBuildDebug
[        ] [  +37 ms] executing: uname -m
[        ] [  +18 ms] Exit code 0 from: uname -m
[        ] [        ] x86_64
[        ] [   +3 ms] executing: [/home/david/fvm/versions/stable/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [   +1 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [        ] 18116933e77adc82f80866c928266a5b4f1ed645
[        ] [        ] executing: [/home/david/fvm/versions/stable/] git tag --points-at 18116933e77adc82f80866c928266a5b4f1ed645
[        ] [   +7 ms] Exit code 0 from: git tag --points-at 18116933e77adc82f80866c928266a5b4f1ed645
[        ] [        ] 2.5.3
[        ] [   +5 ms] executing: [/home/david/fvm/versions/stable/] git rev-parse --abbrev-ref --symbolic @{u}
[        ] [   +1 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] [        ] origin/stable
[        ] [        ] executing: [/home/david/fvm/versions/stable/] git ls-remote --get-url origin
[        ] [   +1 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] [        ] https://github.com/flutter/flutter.git
[        ] [  +33 ms] executing: [/home/david/fvm/versions/stable/] git rev-parse --abbrev-ref HEAD
[        ] [  +16 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] [        ] stable
[        ] [  +27 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [  +50 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] [   +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[        ] [  +22 ms] Initializing file store
[        ] [   +3 ms] Done initializing file store
[        ] [  +19 ms] Skipping target: gen_localizations
[        ] [   +5 ms] Skipping target: gen_dart_plugin_registrant
[        ] [ +231 ms] kernel_snapshot: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /home/david/Dev/Flutter/timer_issue/lib/main.dart}
[        ] [   +6 ms] /home/david/fvm/versions/stable/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/david/fvm/versions/stable/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/home/david/fvm/versions/stable/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --target=flutter --no-print-incremental-dependencies -DFLUTTER_WEB_AUTO_DETECT=true -Ddart.vm.profile=false
-Ddart.vm.product=false --enable-asserts --track-widget-creation --no-link-platform --packages /home/david/Dev/Flutter/timer_issue/.dart_tool/package_config.json --output-dill
/home/david/Dev/Flutter/timer_issue/.dart_tool/flutter_build/53e4350c14238e335317abfe4c521b4b/app.dill --depfile
/home/david/Dev/Flutter/timer_issue/.dart_tool/flutter_build/53e4350c14238e335317abfe4c521b4b/kernel_snapshot.d package:timer_issue/main.dart
[+3794 ms] [+5091 ms] kernel_snapshot: Complete
[ +500 ms] [ +493 ms] debug_android_application: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents:
/home/david/Dev/Flutter/timer_issue/.dart_tool/flutter_build/53e4350c14238e335317abfe4c521b4b/app.dill}
[ +200 ms] [ +226 ms] debug_android_application: Complete
[ +199 ms] [ +160 ms] Persisting file store
[        ] [   +3 ms] Done persisting file store
[        ] [   +2 ms] build succeeded.
[        ] [   +5 ms] "flutter assemble" took 6,335ms.
[  +99 ms] [  +84 ms] ensureAnalyticsSent: 81ms
[        ] [   +1 ms] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 0
[  +99 ms] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
[        ] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preDebugBuild UP-TO-DATE
[        ] > Task :app:compileDebugAidl NO-SOURCE
[        ] > Task :app:compileDebugRenderscript NO-SOURCE
[        ] > Task :app:generateDebugBuildConfig UP-TO-DATE
[  +99 ms] > Task :app:checkDebugAarMetadata UP-TO-DATE
[        ] > Task :app:cleanMergeDebugAssets
[        ] > Task :app:mergeDebugShaders UP-TO-DATE
[        ] > Task :app:compileDebugShaders NO-SOURCE
[        ] > Task :app:generateDebugAssets UP-TO-DATE
[        ] > Task :app:mergeDebugAssets
[  +99 ms] > Task :app:copyFlutterAssetsDebug
[        ] > Task :app:generateDebugResValues UP-TO-DATE
[        ] > Task :app:generateDebugResources UP-TO-DATE
[  +99 ms] > Task :app:mergeDebugResources UP-TO-DATE
[        ] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
[        ] > Task :app:extractDeepLinksDebug UP-TO-DATE
[        ] > Task :app:processDebugMainManifest UP-TO-DATE
[        ] > Task :app:processDebugManifest UP-TO-DATE
[        ] > Task :app:processDebugManifestForPackage UP-TO-DATE
[  +99 ms] > Task :app:processDebugResources UP-TO-DATE
[ +300 ms] > Task :app:compileDebugKotlin UP-TO-DATE
[        ] > Task :app:javaPreCompileDebug UP-TO-DATE
[        ] > Task :app:compileDebugJavaWithJavac UP-TO-DATE
[        ] > Task :app:compileDebugSources UP-TO-DATE
[        ] > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
[        ] > Task :app:processDebugJavaRes NO-SOURCE
[        ] > Task :app:mergeDebugJavaResource UP-TO-DATE
[        ] > Task :app:checkDebugDuplicateClasses UP-TO-DATE
[  +98 ms] > Task :app:dexBuilderDebug UP-TO-DATE
[        ] > Task :app:desugarDebugFileDependencies UP-TO-DATE
[        ] > Task :app:mergeExtDexDebug UP-TO-DATE
[        ] > Task :app:mergeDexDebug UP-TO-DATE
[        ] > Task :app:mergeDebugJniLibFolders UP-TO-DATE
[        ] > Task :app:mergeDebugNativeLibs UP-TO-DATE
[        ] > Task :app:stripDebugDebugSymbols UP-TO-DATE
[        ] > Task :app:validateSigningDebug UP-TO-DATE
[ +299 ms] > Task :app:compressDebugAssets
[+1699 ms] > Task :app:packageDebug
[  +99 ms] > Task :app:assembleDebug
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
[        ] BUILD SUCCESSFUL in 14s
[        ] 32 actionable tasks: 7 executed, 25 up-to-date
[ +379 ms] Running Gradle task 'assembleDebug'... (completed in 15.6s)
[  +24 ms] calculateSha: LocalDirectory: '/home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk'/app.apk
[ +377 ms] ✓  Built build/app/outputs/flutter-apk/app-debug.apk.
[   +1 ms] executing: /home/david/Android/Sdk/build-tools/31.0.0/aapt dump xmltree /home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[   +2 ms] Exit code 0 from: /home/david/Android/Sdk/build-tools/31.0.0/aapt dump xmltree /home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1e
               A: android:compileSdkVersionCodename(0x01010573)="11" (Raw: "11")
               A: package="com.example.timer_issue" (Raw: "com.example.timer_issue")
               A: platformBuildVersionCode=(type 0x10)0x1e
               A: platformBuildVersionName=(type 0x10)0xb
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1e
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=16)
                 A: android:label(0x01010001)="timer_issue" (Raw: "timer_issue")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=21)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.timer_issue.MainActivity" (Raw: "com.example.timer_issue.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=35)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=45)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=49)
                     E: action (line=50)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=52)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=59)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[        ] Stopping app 'app.apk' on KB2003.
[        ] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell am force-stop com.example.timer_issue
[  +51 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell pm list packages com.example.timer_issue
[  +38 ms] package:com.example.timer_issue
[   +1 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell cat /data/local/tmp/sky.com.example.timer_issue.sha1
[  +20 ms] 6c990a0f6ab1cebd3d6527001bd118ec596f659a
[        ] Installing APK.
[   +1 ms] Installing build/app/outputs/flutter-apk/app.apk...
[        ] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 install -t -r /home/david/Dev/Flutter/timer_issue/build/app/outputs/flutter-apk/app.apk
[+2325 ms] Performing Streamed Install
                    Success
[        ] Installing build/app/outputs/flutter-apk/app.apk... (completed in 2,325ms)
[        ] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell echo -n 80267c456d21e41799cb9ad0ba8c2d98d28502d8 > /data/local/tmp/sky.com.example.timer_issue.sha1
[   +9 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell -x logcat -v time -t 1
[ +197 ms] --------- beginning of main
                    11-23 09:55:22.354 D/IHansComunication( 3100): HANS handleMessage: Got message from kernel
[   +4 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez
enable-checked-mode true --ez verify-entry-points true com.example.timer_issue/com.example.timer_issue.MainActivity
[  +74 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.timer_issue/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[+1217 ms] W/FlutterActivityAndFragmentDelegate(24881): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
[ +106 ms] Observatory URL on device: http://127.0.0.1:41323/zvBCWTsrYCE=/
[   +1 ms] executing: /home/david/Android/Sdk/platform-tools/adb -s ac268173 forward tcp:0 tcp:41323
[   +3 ms] 33721
[        ] Forwarded host port 33721 to device port 41323 for Observatory
[   +4 ms] Caching compiled dill
[  +25 ms] Connecting to service protocol: http://127.0.0.1:33721/zvBCWTsrYCE=/
[ +143 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:33721/zvBCWTsrYCE=/.
[  +25 ms] I/flutter (24881): Periodic callback 2021-11-23 09:55:24.092078
[ +108 ms] DDS is listening at http://127.0.0.1:45333/WR5XLrvYaQo=/.
[  +35 ms] Successfully connected to service protocol: http://127.0.0.1:33721/zvBCWTsrYCE=/
[  +38 ms] DevFS: Creating new filesystem on the device (null)
[  +24 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.timer_issue/code_cache/timer_issuePBFHJJ/timer_issue/)
[   +1 ms] Updating assets
[  +44 ms] Syncing files to device KB2003...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +1 ms] <- recompile package:timer_issue/main.dart b8110ab4-fda7-4453-828d-c1aeee52c3bc
[        ] <- b8110ab4-fda7-4453-828d-c1aeee52c3bc
[  +29 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device KB2003... (completed in 31ms)
[        ] Synced 0.0MB.
[        ] <- accept
[  +45 ms] Connected to _flutterView/0xb4000076e8d427b0.
[   +1 ms] Flutter run key commands.
[        ] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[        ] An Observatory debugger and profiler on KB2003 is available at: http://127.0.0.1:45333/WR5XLrvYaQo=/
[ +120 ms] Activating Dart DevTools...
[+2510 ms] Activating Dart DevTools... (completed in 2,510ms)
[ +308 ms] The Flutter DevTools debugger and profiler on KB2003 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:45333/WR5XLrvYaQo=/
[ +438 ms] I/flutter (24881): On pressed 2021-11-23 09:55:27.506217
[+1038 ms] I/flutter (24881): Delayed! 2021-11-23 09:55:28.010871
[+1304 ms] D/ViewRootImpl[MainActivity](24881): windowFocusChanged hasFocus=false inTouchMode=true
[ +826 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.inactive
[ +135 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.paused
[+13205 ms] I/flutter (24881): Periodic callback 2021-11-23 09:55:44.135751
[+19735 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:04.122471
[+19998 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:24.103399
[+19975 ms] I/flutter (24881): Periodic callback 2021-11-23 09:56:44.096007
[+49644 ms] W/DisplayEventDispatcher(24881): dispatcher 0xb400007618d40ab0 ~ ignoring unknown event type 0x6d746f6e
[   +2 ms] W/DisplayEventDispatcher(24881): dispatcher 0xb400007618d40ab0 ~ ignoring unknown event type 0x6d746f6e
[        ] W/DisplayEventDispatcher(24881): dispatcher 0xb400007668d7fa70 ~ ignoring unknown event type 0x6d746f6e
[+2175 ms] I/flutter (24881): AppLifecycleState changed: AppLifecycleState.resumed
[   +3 ms] I/flutter (24881): Application resumed. 2021-11-23 09:57:35.921718
[        ] D/ActivityThread(24881): pid:24881 tid:24881 doframe Callback
[  +21 ms] D/OpScreenModeManager(24881): setRefreshRate parent io.flutter.embedding.android.FlutterView{1a438ae VFED..... ........ 0,0-1080,2355 #1} parent width 1080 parent height 2355 mRatio 1.2
[        ] D/OpScreenModeManager(24881): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{b0af862 V.E...... ........ 0,0-1080,2355} viewRate 1 width 1080 height 2355
[   +1 ms] E/ple.timer_issu(24881): Invalid ID 0x00000001.
[        ] D/OpScreenModeManager(24881): setRefreshRate parent io.flutter.embedding.android.FlutterView{1a438ae VFED..... ........ 0,0-1080,2355 #1} parent width 1080 parent height 2355 mRatio 1.2
[        ] D/OpScreenModeManager(24881): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{b0af862 V.E...... ........ 0,0-1080,2355} viewRate 1 width 1080 height 2355
[   +5 ms] D/DecorView(24881): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@6caeab0[MainActivity]
[   +3 ms] D/ViewRootImpl[MainActivity](24881): windowFocusChanged hasFocus=true inTouchMode=true
[ +825 ms] I/flutter (24881): On pressed 2021-11-23 09:57:36.782580
[+16964 ms] I/flutter (24881): Periodic callback 2021-11-23 09:57:53.748283
[        ] I/flutter (24881): Delayed! 2021-11-23 09:57:53.748653
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
➜ flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on openSUSE Tumbleweed 5.14.14-2-default, locale en_US.UTF-8)
    • Flutter version 2.5.3 at /home/david/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (6 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/david/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /home/david/Android/Sdk
    • Java binary at: /home/david/opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 13.0.0
    • cmake version 3.21.4
    • ninja version 1.10.2
    • pkg-config version 1.8.0

[✓] Android Studio (version 2020.3)
    • Android Studio at /home/david/opt/android-studio
    • 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 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.62.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.28.0

[✓] Connected device (3 available)
    • KB2003 (mobile) • ac268173 • android-arm64  • Android 11 (API 30)
    • Linux (desktop) • linux    • linux-x64      • openSUSE Tumbleweed 5.14.14-2-default
    • Chrome (web)    • chrome   • web-javascript • Google Chrome 96.0.4664.45

• No issues found!
```

</details>