Large number of RemoteServiceExceptions in Google's cast MediaNotificationService

徘徊边缘 提交于 2020-02-26 09:51:30

问题


In the last ~24 hours, we've seen a few thousand crashes within Google's MediaNotificationService:

Fatal Exception: android.app.RemoteServiceException
    Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{f9a4deb u0 <our package name>/com.google.android.gms.cast.framework.media.MediaNotificationService}
    android.app.ActivityThread$H.handleMessage (ActivityThread.java:1855)
    android.os.Handler.dispatchMessage (Handler.java:106)
    android.os.Looper.loop (Looper.java:214)
    android.app.ActivityThread.main (ActivityThread.java:6986)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)

I've experienced similar issues when creating my own foreground service, but as this is within the cast library we have no control over it.

The Chromecast receiver is handled by a third party. We are using:

api "com.google.android.gms:play-services-cast:17.0.0"
api "com.google.android.gms:play-services-cast-framework:17.0.0"

Potential clues:

  • It is happening on OnePlus, Huawei, Samsung, Google, seemingly every manufacturer (and OS level) in numbers correlating to their market share.
  • The crashes are occurring on different lines for different devices (e.g. the above is the Galaxy S9, the S8 crashes on line 1872 instead), so are not grouped together on Crashlytics. This suggests to me it's an OS / Google Play Services level issue.
  • The crashes happen across all active versions of the app, starting at the same time.
  • The crashes have been occurring in low numbers for months, but suddenly spiked over the weekend and show no sign of slowing down.

回答1:


It looks like a known issue:

Issue occured only on HUAWEI devices with Android 9 : P20 pro, P30 pro, P20 lite, P30, P20, Honor View 10, Mate 20 pro

Cast SDK version : Android Sender 16.2.0 (I checked release notes of Android Sender 17.1.0 but no bug fixes)

Here is the crash log from fabric :

Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3ac0035 u0 com.google.android.gms.cast.framework.media.MediaNotificationService}
       at android.app.ActivityThread$H.handleMessage + 2126(ActivityThread.java:2126)
       at android.os.Handler.dispatchMessage + 112(Handler.java:112)
       at android.os.Looper.loop + 216(Looper.java:216)
       at android.app.ActivityThread.main + 7625(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 524(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main + 987(ZygoteInit.java:987)

that a Google engineer says is fixed:

We have a fix for this and that should be released by the next Android Cast client library release.

but they don't know when the fix will be released:

So far we don't have a solid date when the next release will be scheduled. We will update it here or else please do check here https://developers.google.com/cast/docs/release-notes

The release notes don't mention a fix for this.

I'll update this answer if I find anything further.

Edit

This is fixed. See Anjaneesh's answer.




回答2:


The fix has been released on the Android Cast SDK client library v18.0.0 (check the second item of the release notes: https://developers.google.com/cast/docs/release-notes#december-5,-2019)

The crash should be fixed once you update to v18.0.0




回答3:


We are also experiencing this issue with very similar symptoms. We are on cast SDK version 16.1.2

  • Only happening on Android 8 and above. Seems to be linked to the background execution changes here
  • Also low numbers for months. Spiked recently across all app versions. Now looking at numbers in the thousands.
  • There was a play services update on 11th Feb. Could be linked?

What we've tried (Updating to SDK 18.0.0)

Updating to v18.0.0 appears to fix the issue as reported by @Anjaneesh. However, 18.0.0 introduced behaviour changes around the retrieval of custom data. We have observed that the custom data we supply to the remoteMediaClient's mediaInfo (and then try to retrieve) gets nulled when the sender app disconnects and then re-connects. This will need guarding against if you aren't already!



来源:https://stackoverflow.com/questions/60148919/large-number-of-remoteserviceexceptions-in-googles-cast-medianotificationservic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!