Status Update
Comments
su...@google.com <su...@google.com> #3
pu...@gmail.com <pu...@gmail.com> #4
fe...@tv2.no <fe...@tv2.no> #5
The crash seems to be slightly increasing with Android 12. Could this error being handled on MediaRouter library?
pu...@gmail.com <pu...@gmail.com> #6
Still happening more and more. Here's an Android 11 stack trace. Please do something about it, even if it is a Samsung specific bug, as it cannot be worked-around at the app level:
java.lang.IllegalArgumentException: Bad stream type -1
at android.os.Parcel.createExceptionOrNull(Parcel.java:2441)
at android.os.Parcel.createException(Parcel.java:2421)
at android.os.Parcel.readException(Parcel.java:2404)
at android.os.Parcel.readException(Parcel.java:2346)
at android.media.IAudioService$Stub$Proxy.getDevicesForStream(IAudioService.java:6999)
at android.media.MediaRouter.isAudioPathA2DPStatic(MediaRouter.java:3310)
at android.media.MediaRouter.selectDefaultRouteStatic(MediaRouter.java:1172)
at android.media.MediaRouter.removeRouteStatic(MediaRouter.java:1288)
at android.media.MediaRouter.removeUserRoute(MediaRouter.java:1244)
at androidx.mediarouter.media.MediaRouterJellybean.removeUserRoute(MediaRouterJellybean.java:110)
at androidx.mediarouter.media.SystemMediaRouteProvider$JellybeanImpl.onSyncRouteRemoved(SystemMediaRouteProvider.java:493)
at androidx.mediarouter.media.MediaRouter$GlobalMediaRouter$CallbackHandler.syncWithSystemProvider(MediaRouter.java:3654)
at androidx.mediarouter.media.MediaRouter$GlobalMediaRouter$CallbackHandler.handleMessage(MediaRouter.java:3622)
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:8633)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.audio.AudioService.ensureValidStreamType(AudioService.java:6407)
at com.android.server.audio.AudioService.getDevicesForStream(AudioService.java:6740)
at android.media.IAudioService$Stub.onTransact(IAudioService.java:3157)
at android.os.Binder.execTransactInternal(Binder.java:1215)
at android.os.Binder.execTransact(Binder.java:1179)
android.os.RemoteException: Remote stack trace:
at com.android.server.audio.AudioService.ensureValidStreamType(AudioService.java:6407)
at com.android.server.audio.AudioService.getDevicesForStream(AudioService.java:6740)
at android.media.IAudioService$Stub.onTransact(IAudioService.java:3157)
at android.os.Binder.execTransactInternal(Binder.java:1215)
at android.os.Binder.execTransact(Binder.java:1179)
pu...@gmail.com <pu...@gmail.com> #7
Stack trace above is from a Samsung Android 12 device (not 11 as stated).
sz...@gmail.com <sz...@gmail.com> #8
Have same problem. For now 67 users affected, mostly android 12, 100% samsung
da...@bt.com <da...@bt.com> #9
It'd be great if it could be caught, but ultimately this looks like a Samsung bug.
ba...@google.com <ba...@google.com>
ma...@persgroep.net <ma...@persgroep.net> #10
- 100% Samsung, of which most are of the type Galaxy A52s 5G and Galaxy A51
- 100% Android 12
- 98% App in background
Unfortunately we don't seem to be the ones initiating some sort of action so we can't catch the exception in our application code.
pu...@gmail.com <pu...@gmail.com> #11
This is happening more and more... Apparently, there does not seem to be an incentive from Google to workaround it in this library probably because "not our problem" (it is a Samsung bug). The only thing we can do is to decompile mediarouter and catch the IllegalArguementException ourselves...
sz...@gmail.com <sz...@gmail.com> #12
Any chance to fix this in somehow? 200+ users in my app has this error. 100% Samsung 99% - android 12 1% - android 11
pu...@gmail.com <pu...@gmail.com> #13
I finally patched androidx.mediarouter:mediarouter:1.3.0
with IllegalArgumentException
:
in androidx.mediarouter.media.MediaRouterJellybean
, I changed:
public static void removeUserRoute(Object routerObj, Object routeObj) {
((MediaRouter)routerObj).removeUserRoute((MediaRouter.UserRouteInfo)routeObj);
}
to:
public static void removeUserRoute(Object routerObj, Object routeObj) {
try {
((MediaRouter)routerObj).removeUserRoute((MediaRouter.UserRouteInfo)routeObj);
}
catch (IllegalArgumentException ex) {
Log.w(TAG, "android.media.MediaRouter.removeUserRoute() failed with IllegalArgumentException (Samsung Android 12 bug work-around)", ex);
}
}
To use it:
- download
https://bubblesoftapps.com/mediarouter-samsung-fix/mediarouter-samsung-fix-1.3.0.zip - unzip in your .m2/repository folder so you end up having /path/to/.m2/repository/androidx/mediarouter/mediarouter-samsung-fix/
- update your build.gradle to use it: replace
implementation 'androidx.mediarouter:mediarouter:1.3.0'
withimplementation 'androidx.mediarouter:mediarouter-samsung-fix:1.3.0'
- if you have an AndroidX dependency pulling 'androidx.mediarouter:mediarouter', you will have to exclude it so it does not get in the way (duplicate classes). For example, the cast sdk needs it:
implementation('com.google.android.gms:play-services-cast:21.0.1') {
// replaced by mediarouter-samsung-fix
exclude group: 'androidx.mediarouter'
}
ol...@google.com <ol...@google.com> #14
We have made Samsung aware of this issue. It makes sense for us to catch the exception in the AndroidX MediaRouter library, as per #13, as well.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit c3805953951058b509f629980ffad858c7a531ee
Author: Oliver Woodman <olly@google.com>
Date: Fri May 20 13:35:47 2022
Workaround for crash removing user routes.
Test: N/A
Bug: 202931542
Change-Id: Ia25cd716cf2cd48ec298aff04e13751cbcb27d45
M mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouterJellybean.java
pu...@gmail.com <pu...@gmail.com> #16
Thanks for the fix (or rather, work-around) !
ol...@google.com <ol...@google.com> #17
Samsung have a fix for the underlying issue, and will roll it out to their devices in future maintenance releases.
pu...@gmail.com <pu...@gmail.com> #18
Glad to hear that ! Thanks for your report to Samsung, and for Samsung devs to fix it.
bl...@moshikids.com <bl...@moshikids.com> #19
Thanks!
ol...@google.com <ol...@google.com> #20
AndroidX MediaRouter 1.3.1 will pick up the fix, and is scheduled for release on July 27th.
bu...@google.com <bu...@google.com> #21
na...@google.com <na...@google.com> #22
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.mediarouter:mediarouter:1.4.0-alpha01
Description
Component used: androidx.mediarouter:mediarouter Version used: 1.2.5 Devices/Android versions reproduced on: Samsung / Android 11
I've seen crash below happening on Samsung Android 11 devices (various models). It is fairly rare, as it happened only for 5 users 1 or twice, in an app with lots of users. Maybe it can be worked-around catching IllegalArgumentException.