plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: Stream emitting same values after app being in background on device Xiaomi Mi MIX 2 (Android)

Open sentd94 opened this issue 3 years ago • 0 comments

Platform

Android 9

Plugin

sensors_plus

Version

1.3.4+1

Flutter SDK

32

Steps to reproduce

Note: I could not reproduce this on an Emulator device. I also don't have another physical device here to test this. So this might be a MIUI specific issue.

  • Put the app in background (on Android press the Home Button).

  • Unfortunately you have to wait now for a couple of minutes to reproduce (I waited for 6 minutes, might be possible sooner).

  • Now put the app in front again. The stream is going to emit the same values over and over no matter what.

Code Sample

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'dart:math';
import 'package:sensors_plus/sensors_plus.dart';

final speedProvider = StreamProvider<double>((ref) {
  return userAccelerometerEvents.map((event) =>
      sqrt(event.x * event.x + event.y * event.y + event.z * event.z));
});

class FrontPageWidget extends ConsumerWidget {
  const FrontPageWidget({Key? key}) : super(key: key);
  static const routeName = '/frontPage';

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Main Page'),
      ),
      body: Text(ref.watch(speedProvider).value.toString()),
    );
  }
}

Logs

[ +151 ms] executing: C:\Users\Dave\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3c4f932 shell pm list packages com.example.sample2
[ +125 ms] package:com.example.sample2
[   +1 ms] executing: C:\Users\Dave\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3c4f932 shell cat /data/local/tmp/sky.com.example.sample2.sha1
[  +97 ms] 17eb3c54c30b5b5a16b4341e2913869e34f72c8c
[   +1 ms] Latest build already installed.
[        ] executing: C:\Users\Dave\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3c4f932 shell -x logcat -v time -t 1
[ +168 ms] --------- beginning of main
                    08-15 10:55:33.297 D/NxpTml  (  731): PN54X - Invoking I2C Read.....
[   +5 ms] executing: C:\Users\Dave\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3c4f932 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-dart-profiling true --ez enable-checked-modetrue --ez verify-entry-points true com.example.sample2/com.example.sample2.MainActivity
[ +151 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.sample2/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[ +541 ms] Observatory URL on device: http://127.0.0.1:39978/_5PBcyifSjg=/
[   +1 ms] executing: C:\Users\Dave\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3c4f932 forward tcp:0 tcp:39978
[  +61 ms] 60529
[        ] Forwarded host port 60529 to device port 39978 for Observatory
[   +3 ms] Caching compiled dill
[  +37 ms] Connecting to service protocol: http://127.0.0.1:60529/_5PBcyifSjg=/
[ +231 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:60529/_5PBcyifSjg=/.
[ +160 ms] DDS is listening at http://127.0.0.1:60532/o7gPCdEza-k=/.
[  +46 ms] Successfully connected to service protocol: http://127.0.0.1:60529/_5PBcyifSjg=/
[  +65 ms] DevFS: Creating new filesystem on the device (null)
[  +30 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.sample2/code_cache/sample2VDVOBT/sample2/)
[   +2 ms] Updating assets
[ +103 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466.
[   +4 ms] Syncing files to device Mi MIX 2...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +1 ms] Processing bundle.
[        ] <- recompile package:sample2/main.dart 241073d3-a736-4bcb-8a7a-0a96587dea6c
[        ] <- 241073d3-a736-4bcb-8a7a-0a96587dea6c
[   +1 ms] Bundle processing done.
[+1424 ms] D/vndksupport(19862): Loading /vendor/lib64/hw/[email protected] from current namespace instead of sphal namespace.
[        ] D/vndksupport(19862): Loading /vendor/lib64/hw/gralloc.msm8998.so from current namespace instead of sphal namespace.
[+1017 ms] Updating files.
[        ] DevFS: Sync finished
[   +1 ms] Syncing files to device Mi MIX 2... (completed in 2.449ms)
[        ] Synced 0.0MB.
[   +1 ms] <- accept
[   +9 ms] Connected to _flutterView/0x76566dc020.
[   +2 ms] Flutter run key commands.
[   +1 ms] 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 Mi MIX 2 is available at: http://127.0.0.1:60532/o7gPCdEza-k=/
[   +1 ms] The Flutter DevTools debugger and profiler on Mi MIX 2 is available at: http://127.0.0.1:9102?uri=http://127.0.0.1:60532/o7gPCdEza-k=/
[+4482 ms] I/example.sample(19862): ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000

Flutter Doctor

[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale de-DE)
    • Flutter version 3.0.5 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\Dave\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.6)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30611.23
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • 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.12+7-b1504.28-7817840)

[√] VS Code (version 1.70.1)
    • VS Code at C:\Users\Dave\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[√] Connected device (5 available)
    • Mi MIX 2 (mobile)            • 3c4f932       • android-arm64  • Android 9 (API 28)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19044.1889]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 104.0.5112.81
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 102.0.1245.33

[√] HTTP Host Availability
    • All required HTTP hosts are available

sentd94 avatar Aug 15 '22 09:08 sentd94