Skip to content

Service stops when activity closes and it's foreground #834

@nt4f04uNd

Description

@nt4f04uNd

Which API doesn't behave as documented, and how does it misbehave?
If processing state was idle, then became ready and playing didn't change, something goes wrong, not sure what exactly, perhaps MediaSession should be reactivated.

Minimal reproduction project
https://github.com/nt4f04unds-archive/issues/tree/audio_service_834

To Reproduce (i.e. user steps, not code)

  1. Run the sample on Android 11
  2. Start the playback
  3. Switch media item
  4. Dismiss the activity
  5. The service stops while playing

Error messages

n/a

Expected behavior
Service shouldn't stop

Screenshots
n/a

Runtime Environment (please complete the following information if relevant):

  • Device: emulator
  • OS: Android 11

Flutter SDK version

Details
[√] Flutter (Channel master, 2.6.0-12.0.pre.136, on Microsoft Windows [Version 10.0.19041.1237], locale ru-RU)
    • Flutter version 2.6.0-12.0.pre.136 at C:\dev\src\flutter
    • Upstream repository [email protected]:nt4f04und/flutter.git
    • FLUTTER_GIT_URL = [email protected]:nt4f04und/flutter.git
    • Framework revision aaa14b8004 (5 hours ago), 2021-09-29 06:03:04 -0400
    • Engine revision bccb3a57eb
    • Dart version 2.15.0 (build 2.15.0-156.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\danya\AppData\Local\Android\sdk
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] 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.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 4.1)
    • Android Studio at C:\Program Files\Android\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 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.3
    • 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

[√] VS Code (version 1.60.2)
    • VS Code at C:\Users\danya\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (5 available)
    • Redmi Note 5 (mobile)   • 40c9f14       • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19041.1237]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 94.0.4606.61
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 94.0.992.31

! Doctor found issues in 1 category.

Additional context
This causes other side effects, e.g. the service gets destroyed while the activity is reattaching to it, which prevents proper patching of #671

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions