Skip to content
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

App crashes when in background #9070

Closed
6 tasks done
WorkHard4470 opened this issue Oct 5, 2022 · 22 comments · Fixed by #10578
Closed
6 tasks done

App crashes when in background #9070

WorkHard4470 opened this issue Oct 5, 2022 · 22 comments · Fixed by #10578
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)

Comments

@WorkHard4470
Copy link

WorkHard4470 commented Oct 5, 2022

Checklist

  • I am able to reproduce the bug with the latest version.
  • I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • I have read the FAQ and my problem isn't listed.
  • I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • This issue contains only one bug.
  • I have read and understood the contribution guidelines.

Affected version

0.24.0

Steps to reproduce the bug

Use multitasking to go back to NewPipe app and can cause crash. Foreground running occured. There was a problem with search suggestions which caused by their multitasking action.

Expected behavior

The app worked fine without errors.

Actual behavior

Crashes with running in foreground service exception unable to start with correct time android.app.ForegroundServiceDidNotStartInTimeException as it appears it can't look up search suggestions.

Screenshots/Screen recordings

See logs below.

Logs

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: PH
  • Content Language: en-PH
  • App Language: en_PH
  • Service: none
  • Version: 0.24.0
  • OS: Linux Android 12 - 31
Crash log

android.app.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{a13ad15 u0 org.schabi.newpipe/.player.PlayerService}
	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2078)
	at android.app.ActivityThread.access$2800(ActivityThread.java:259)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2303)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:233)
	at android.os.Looper.loop(Looper.java:344)
	at android.app.ActivityThread.main(ActivityThread.java:8248)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)


Affected Android/Custom ROM version

Android 12 [Global India ROM, realme UI 3.0]

Affected device model

realme 8 4G

Additional information

No response

@WorkHard4470 WorkHard4470 added bug Issue is related to a bug needs triage Issue is not yet ready for PR authors to take up labels Oct 5, 2022
@WorkHard4470

This comment was marked as spam.

@tsiflimagas
Copy link
Contributor

I don't understand what you're writing in your comment, but this appears to be a duplicate of #9053, which in return appears to be a duplicate of #9030, and eventually this crash was described in #8646 (comment).

@opusforlife2
Copy link
Collaborator

@tsiflimagas Sure? I'm no dev, but the STRs don't seem similar, despite the exception possibly being the same.

@WorkHard4470
Copy link
Author

There could be a problem by clicking the search history. Follows app crash.

@tsiflimagas
Copy link
Contributor

@tsiflimagas Sure? I'm no dev, but the STRs don't seem similar, despite the exception possibly being the same.

Tbh I had by doubts thinking it again, as I'm not a developer either. Let's wait for one I guess.

@Rominet13
Copy link

Rominet13 commented Oct 6, 2022

I noticed the same since the last version. I haven't been using the app for several hours (at least 6h), before I get the error.
Same as #9053, and #9063

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: GB
  • Content Language: en
  • App Language: fr_FR
  • Service: none
  • Version: 0.24.0
  • OS: Linux Nokia/Phoenix_00WW/PNX_sprout:11/RKQ1.200906.002/00WW_6_210:user/release-keys 11 - 30
Crash log

android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{d0aaf0a u0 org.schabi.newpipe/.player.PlayerService}
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2006)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7697)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)


@EthanZeigler
Copy link

I can confirm what @Rominet13 said. The app doesn't even have to be focused for this to occur. Just having the app in the background (not manually swiping closed from switcher) is enough to trigger the error. Newpipe will take focus back from whatever the current app is to display a near identical error to everyone else. I'm not sure what I would have done to cause it given the app wasn't open.

@opusforlife2 opusforlife2 changed the title Foreground Running App Crash App crashes when in background Oct 7, 2022
@opusforlife2
Copy link
Collaborator

I've gotten a report about this from a user, too. The app can randomly crash while the user is busy using some other app.

@Rominet13
Copy link

Rominet13 commented Oct 7, 2022

Ok, it always appears when disconnecting (and sometimes when connecting) bluetooth devices like a car or loud speaker (My watch is connected too but I don't think it changes anything.)
Way to reproduce : use normally (watch some video, or listen music in background), quit the app. And after some time, connect and disconnect to a Bluetooth device like a car.

@opusforlife2
Copy link
Collaborator

Right. That's a known problem and has more to do with Android. Before version 0.24.0, you just got a blank player notification, since Newpipe was the last "media player" app used. Now it causes a crash.

@Stypox This seems actionable now. Is there a way to prevent Newpipe being seen as a media app by the OS? It obviously has something to do with the changed player code, but we might be able to bypass the problem entirely.

@opusforlife2
Copy link
Collaborator

Can you all confirm that you haven't disabled the Newpipe player notification in your OS settings? I'm interested in knowing if your player notification is showing just fine and you still get this error.

I'm trying to narrow this bug down and the lack of the player notification may be a cause, since that's what Android uses to determine if the app should be kept in memory or not.

@Rominet13
Copy link

Rominet13 commented Oct 8, 2022

If by "Newpipe player notification", you mean the "Hide player when the media session has ended (the player allows you to resume a session from the expanded quick setting panel)", it is disabled. I have never changed it... I didn't know it exists^^.

(All other notification are on by default for the app)

@opusforlife2
Copy link
Collaborator

I'm... not sure, actually, if that Android 11+ setting matters. What I'm asking specifically is that when you play a video in the main player, popup player, or the background player, does the player notification show in the notification shade?

@Rominet13
Copy link

Yes the player is in the notification shade, and I use it.

@opusforlife2
Copy link
Collaborator

Alright, that's a dead end, then. Thanks for confirming!

@kirkawolff

This comment was marked as off-topic.

@esibun
Copy link

esibun commented Oct 14, 2022

This looks like the same issue that I have started seeing over the past week or two with my NewPipe client.

Reproduction steps for me were similar to already mentioned: Play a video in background, stop playback, then connect the phone to the car (or presumably any other Bluetooth device that causes autoplay).

I was able to create a Tasker task to take over media events and saw the crashes go away which confirms it was definitely Bluetooth autoplay which triggered the bug.

I've had this happen both with the player in the notification shade and after dismissing the player by hitting the "X" in the lower right.

Pressing "Play" on a pair of headphones also seems to trigger the bug.

@kirkawolff
Copy link

I get this error on grapheneos

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US
  • Service: none
  • Version: 0.24.0
  • OS: Linux Android 13 - 33
Crash log

android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{b6458a5 u0 org.schabi.newpipe/.player.PlayerService}
	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2007)
	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1978)
	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2243)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7904)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ExecInit.main(ExecInit.java:49)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1936)
	at android.app.ContextImpl.startForegroundService(ContextImpl.java:1891)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
	at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:931)
	at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:703)
	at androidx.media.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:115)
	at android.app.ActivityThread.handleReceiver(ActivityThread.java:4337)
	at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
	... 9 more


@opusforlife2
Copy link
Collaborator

@esibun Could you confirm the bug for 0.24.1, please?

@esibun
Copy link

esibun commented Nov 9, 2022

Tried this earlier against 0.24.1 and was unable to reproduce. Might be fixed but should be able to say for sure this afternoon.

@EthanZeigler
Copy link

EthanZeigler commented Nov 9, 2022 via email

@cohesive-flight
Copy link

cohesive-flight commented Nov 22, 2022

I've also been experiencing this issue about several times a day for the past two weeks. I am using the SponsorBlock fork, but the log is similar (and nearly identical to @kirkawolff's)

For the log below, I only had NewPipe paused in the background while scrolling through another app. I was using Bluetooth ear buds, but I wasn't doing anything with them at that time. Furthermore, pressing play from them does not cause NewPipe to crash in my case, unlike what others have mentioned. I also don't have Google Play Services installed.

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US
  • Service: none
  • Version: 0.24.1
  • OS: Linux Android 13 - 33 (Graphene OS)
Crash log

android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{d49c7ac u0 org.polymorphicshade.newpipe/org.schabi.newpipe.player.PlayerService}
	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2007)
	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1978)
	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2243)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7904)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ExecInit.main(ExecInit.java:49)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1936)
	at android.app.ContextImpl.startForegroundService(ContextImpl.java:1891)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
	at androidx.core.content.ContextCompat$Api26Impl$$ExternalSyntheticApiModelOutline0.m(Unknown Source:0)
	at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:931)
	at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:703)
	at org.schabi.newpipe.player.helper.PlayerHolder.startService(PlayerHolder.java:126)
	at org.schabi.newpipe.fragments.detail.VideoDetailFragment$4.onReceive(VideoDetailFragment.java:1496)
	at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1790)
	at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	... 8 more


@SameenAhnaf SameenAhnaf added queue Issue is related to queueing and removed needs triage Issue is not yet ready for PR authors to take up labels Jan 18, 2023
@AudricV AudricV added player Issues related to any player (main, popup and background) and removed queue Issue is related to queueing labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)
Projects
None yet
10 participants