-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Crash: ForegroundServiceDidNotStartInTimeException #1676
Comments
If you do those two things I'll reopen this issue. |
@jspizziri
|
We still see this as well with RNTP 3.2.0 across a wide array of Samsung devices |
I'm seeing this issue too on Samsung devices
|
@puckey Are you seeing this lately in your crash reports? (by the way, I use Bugsnag, do you?) |
We are seeing lots of these errors on Android 12 and 13. It seems like its mainly Samsung, e.g. models S10, S20, S21 and S22. I currently have not been able to reproduce this on my own phone in development.. Error
StackTraceLast startServiceCommon() call for this service was made here
|
Same thing happening here RNTP v3.2.0, all incidents for us are on Samsung Galaxy devices on Android 13 |
@puckey @jspizziri @mpivchev Sorry to ping you all, I have unfortunately not been able to reproduce this locally yet, as I'm not sure what is causing this, and I'm kind of stuck. It seems this is related to the MediaButtonReceiver from the AndroidManifest.xml in RNTP:
As the stacktrace is throwing because in file MediaButtonReceiver.java that's included via KotlinAudio is trying to start the service again:
Where the code on that line is:
Entire function:
All errors are in the background, using RNTP 3.2.0 and multiple Android versions as mentioned earlier (seen it on 11, 12 and 13). It looks like this is some media event being sent that's not being handled as it should. I will gladly debug this more, but I wanted to check in to see if you have any pointers/ideas/thoughts as to how this might be reproduced given the above information? If the MediaButtonReceiver truly is required only on pre-lollipop (API level < 21) devices, we could perhaps just remove this receiver, as KotlinAudio has a minSdk of 21 and the RNTP example app has a minSdk of 21. Will try this locally with patch-package and see if anything breaks. Do you know of any reason not to remove it? |
The problem is not from react native track players but from exoplayer and androidx.media3. There are in facts 2 bugs : one on samusung + android 11 and 12 and on on android 13. A version bump in Kotlin Audio could be a good idea. On my side I forced the resolution to latest media lib adding in build.gradle and released a new version one week ago: configurations.all { It seems that it actually works as I do not see anything else than android 13 errors. Note that the second issue point to the exact problem you are describing with MediaButtonReceiver |
Thanks for the investigation @martinmidtsund . I'm getting several crash reports of this per day. @dcvz or @jspizziri Any thoughts or suggestions on what we should do here? Upgrade the exoplayer? |
@bradleyflood It's hard to say. Not being able to repro makes it almost impossible to fix. I do think there's an exoplayer upgrade on the way though. |
@matthieuMay Thanks for the input! Have seen that issue, but couldn't find that they replicated the same fix from the media beta (androidx/media@acd9e58) into Exoplayer v2.18.2 (https://github.com/google/ExoPlayer/releases), though they say it should be parity between them. 🤷♂️ If the new version of ExoPlayer fixes the issues for versions < 13 that's great. We'll try removing the duplicate media-receiver first, then bump the ExoPlayer version, to see what does what. :) |
@matthieuMay have you seen anymore crashes on Android 12 since adding |
@SMJ93 sadly it came back after 10 days without any errors. I guess it improves a bit the situation but it is not 100% |
Also see this error in version 3.2, I only see this crashes on Android 12 devices.
|
@jspizziri Seeing this error reported a lot on google play console any reason why this is closed has a solution been found? |
@aidan2129 this issue seems to be with ExoPlayer (an upstream dependency), and it doesn't sound like it's been fixed there from what I can tell. I had originally closed it because no one was able to create a reliable reproduction in the example app. I'll reopen it, but all it will be is a placeholder to upgrade ExoPlayer once it's fixed. |
@jspizziri We have had the following patch running in production for 14 days now, and this and related errors has disappeared.
If the MediaButtonReceiver truly is required only on pre-lollipop (API level < 21) devices, we could perhaps just remove this receiver in the library, as KotlinAudio has a minSdk of 21 and the RNTP example app has a minSdk of 21? |
@martinmidtsund interesting, that's good to know. However, I'm concerned that removing that might have unintended side effects. I just quickly glanced at the documentation and it seems that a receiver might be necessary to control wired/wireless headset interactions. Have you tested that in your app? |
@jspizziri We are currently seeing this issue, so we haven't gotten to testing jump forward or backward, but play, pause and volume functions well from wireless bluetooth headset works. (At least with what I'm testing on) |
@martinmidtsund thanks for the info. If you're able to dive into the details with what that receiver actually does and can say create a PR with documentation on why you're confident it wouldn't cause a side effect, I'd happily look deeper into it. |
facing the same issue Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{e58ddc6 u0 com.inspiredmumma/com.doublesymmetry.trackplayer.service.MusicService} Device Info: |
@matthieuMay we have seen an increase in crashes since forcing We were able to reduce the amount of crashes by removing unnecessary calls to I would suggest auditing everywhere you interact with the Hopefully the upstream dependency exoplayer release a fix soon 🤞 |
We are running the patch from @martinmidtsund in prod on ~6.3k devices and have seen this error completely disappear with no complaints from users. We do not support Android < 21. |
Want to open a PR with this change? |
@dcvz Yes, I think I can manage it in a couple of days. Have some untested additions to it as well, but can discuss that in a draft PR. |
Beautiful. I would say make this PR against the v3.2 branch as the main branch is already starting preparations for our next release with other stability but breaking changes. |
@dcvz i have some concerns about this approach that I mention here #1676 (comment) But perhaps it's not a problem? I suppose we can test. |
@jspizziri I can set up a PR draft where we can discuss and list test results with the proposed changes? |
Thanks for fixing this @martinmidtsund! |
Hi guys, I'm still getting this error which is happening Android 13, basically AndroidX:
|
@martinmidtsund shouldn't we publish a new version here after merging this? at least the yarn registry still is pointing to the old version. |
should no longer be necessary and causes issues on Samsung devices See issue doublesymmetry/react-native-track-player#1676
Does the latest version (3.2.0) include the PR to fix it by @martinmidtsund? I'm having production crashes for Samsung Android 13 devices |
Same question here: Using 3.2.0 and getting crashes on Samsung and Nokia devices. Edit: after inspecting https://github.com/doublesymmetry/react-native-track-player/blob/v3.2/android/src/main/AndroidManifest.xml it seems that the PR is indeed merged in the 3.2 release. It probably doesn't solve all the issues. |
Describe the Bug
android.app.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{334a779 u0 nz.co.nbr/com.doublesymmetry.trackplayer.service.MusicService}
using RNTP 3.0.0
I haven't been able to reproduce this crash in my dev environment, I can just see it happening to users via crashalytics
Looks like its only happening for android 12 / API level 32
Environment Info:
System:
OS: macOS 12.5.1
CPU: (8) arm64 Apple M1 Pro
Memory: 85.55 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.7.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.17.0 - /opt/homebrew/bin/npm
Watchman: 2022.08.15.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 31, 33
Build Tools: 30.0.3, 31.0.0, 33.0.0
System Images: android-33 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 18.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.0.0 => 18.0.0
react-native: ^0.69.4 => 0.69.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
How I can Help
it looks like the google docs says startForeground needs to be called within 5 seconds of context.startService
but I can't see where NotificationState.POSTED gets called to trigger the event which calls startForeground.
my three current theories as to why this crash is occurring is
Unsure how to investigate/ make tweaks to investigate any of these. Assumptions I have made is that startForegound is only called in NotificationState.POSTED. If true, questions are:
The text was updated successfully, but these errors were encountered: