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

android.app.RemoteServiceException: while trying to manage foreground service #58

Open
vkryl opened this issue Oct 8, 2021 · 4 comments
Labels
bug Issues describing that something went wrong task Issues that describe not an issue but the task

Comments

@vkryl
Copy link
Member

vkryl commented Oct 8, 2021

Well-established and the most reported crash. It happens frequently in calls and while playing music, most likely usually without user even noticing.

It seems that is either something is improperly managed by Telegram X, or this crash is coming from some bugged Android versions.

As of 27th March 2020 there were 50,047 reports, 19,633 impacted users.

Saving this issue here in 2021 in case somebody would like to investigate this issue and build a solid conclusion on why this happens.

android.app.RemoteServiceException: 
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1881)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6942)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
@vkryl vkryl added the bug Issues describing that something went wrong label Oct 8, 2021
@vkryl
Copy link
Member Author

vkryl commented Nov 13, 2023

Occasionally reproduces on high-end Samsung Galaxy S22 Ultra. Noticeable only on debug builds on app launch, as background crashes are invisible to user on Samsung devices by default.

Stack trace for commit 758bb7a:

=== Stack Trace Dump ===
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{8fbffcc u0 org.thunderdog.challegram/.service.ForegroundService}
android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{8fbffcc u0 org.thunderdog.challegram/.service.ForegroundService}
	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2245)
	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2216)
	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8762)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

@vkryl
Copy link
Member Author

vkryl commented Nov 13, 2023

Current guesses:

  1. Foreground notification hides too fast after being shown, so system doesn't track that the notification was actually shown and there's no reason to force crash from the system side
  2. Foreground service is being started while main thread is frozen for some reason, so foreground notification isn't shown
  3. (Unlikely) Bug in foreground notification detection in the system

It's possible that none of them are correct, just leaving for whatever found solution in future.

@vkryl vkryl added the task Issues that describe not an issue but the task label Nov 13, 2023
@vkryl vkryl pinned this issue Nov 13, 2023
@TGX-Android TGX-Android deleted a comment from Anatolijborodin Feb 5, 2024
@TGX-Android TGX-Android deleted a comment from Anatolijborodin Feb 5, 2024
@TGX-Android TGX-Android deleted a comment from Syahwanzairy00 Feb 20, 2024
@TGX-Android TGX-Android deleted a comment from Anatolijborodin Feb 20, 2024
@Saminkamoje2810
Copy link

android.app.RemoteServiceException:
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1881)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6942)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

@Saminkamoje2810
Copy link

Well-established and the most reported crash. It happens frequently in calls and while playing music, most likely usually without user even noticing.

It seems that is either something is improperly managed by Telegram X, or this crash is coming from some bugged Android versions.

As of 27th March 2020 there were 50,047 reports, 19,633 impacted users.

Saving this issue here in 2021 in case somebody would like to investigate this issue and build a solid conclusion on why this happens.

android.app.RemoteServiceException: 
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1881)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6942)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

#58 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing that something went wrong task Issues that describe not an issue but the task
Projects
None yet
Development

No branches or pull requests

4 participants
@vkryl @Saminkamoje2810 and others