Status Update
Comments
vi...@google.com <vi...@google.com>
ra...@google.com <ra...@google.com> #2
there are some image for help
[Deleted User] <[Deleted User]> #3
hello?
vi...@google.com <vi...@google.com>
ch...@google.com <ch...@google.com>
ch...@google.com <ch...@google.com> #4
The stack trace shows the player is blocked when the DefaultBandwidthMeter
constructor is registering a BroadcastReceiver (
Maybe that's a symptom of the device being overloaded at the time. The DefaultBandwidthMeter
uses a singleton instance and needs this code to be executed, so there's no staightforward way to ignore/not execute this code.
Maybe one way to work around the ANR is to move things around and instantiate the DefaultBandwidthMeter
eagerly before instantiating the player. Just call DefaultBandwidthMeter.getSingletonInstance()
either on the app main thread long before you need to instantiate the player, or try on a background thread. This might shuffle things a bit, but it will not necessarily solve the problem, it might only move ANRs to different locations.
[Deleted User] <[Deleted User]> #5
[Deleted User] <[Deleted User]> #6
However, this only applies to one stack-trace. However, for this issue, we have numerous separate stack-traces, and I don't believe we will be able to reduce the count by simply managing one of them. Because each stack is distinct. I'm agreed with you that this could be a device stalled issue owing to a large number of process overload. But what would you suggest in general, shall we choose another means of preparing the player so that low performance phones can also build player efficiently, and we'll lower the high number of ANR for this or we don't have no other best possible mechanism to create such player.
And why this is unique to Android 11 and only appears when the application is in the background. According to Firebase, 98 percent of incidents occur on Android 11 and 100 percent of incidents occur when the device is in the background state.
Sharing some more incidence stack-trace.
-----------------------------------------------------------------------------------------------------------------------
Stack-trace : 1
-----------------------------------------------------------------------------------------------------------------------
main (runnable): tid=1 systid=14220
at com.google.android.exoplayer2.ExoPlayerImpl.<init>(ExoPlayerImpl.java)
at com.google.android.exoplayer2.SimpleExoPlayer.<init>(SimpleExoPlayer.java:685)
at com.google.android.exoplayer2.SimpleExoPlayer$Builder.build(SimpleExoPlayer.java:558)
at com.audiomack.playback.Players.initExoPlayer(Players.java:60)
at com.audiomack.playback.Players.getSimpleExoPlayerInstance(Players.java:65)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at kotlin.SynchronizedLazyImpl.getValue(SynchronizedLazyImpl.java:74)
at com.audiomack.playback.MusicService.getExoPlayer(MusicService.java:147)
at com.audiomack.playback.MusicService.onCreate(MusicService.java:232)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4650)
at android.app.ActivityThread.access$1600(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2185)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
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:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
-----------------------------------------------------------------------------------------------------------------------
Stack-trace : 2
-----------------------------------------------------------------------------------------------------------------------
main (waiting): tid=1 systid=10000
at java.lang.Object.wait(Object.java)
at java.lang.Object.wait(Object.java:442)
at java.lang.Object.wait(Object.java:568)
at android.os.HandlerThread.getLooper(HandlerThread.java:86)
at com.google.android.exoplayer2.ExoPlayerImplInternal.<init>(ExoPlayerImplInternal.java:267)
at com.google.android.exoplayer2.ExoPlayerImpl.<init>(ExoPlayerImpl.java:188)
at com.google.android.exoplayer2.SimpleExoPlayer.<init>(SimpleExoPlayer.java:685)
at com.google.android.exoplayer2.SimpleExoPlayer$Builder.build(SimpleExoPlayer.java:558)
at com.audiomack.playback.Players.initExoPlayer(Players.java:60)
at com.audiomack.playback.Players.getSimpleExoPlayerInstance(Players.java:65)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at kotlin.SynchronizedLazyImpl.getValue(SynchronizedLazyImpl.java:74)
at com.audiomack.playback.MusicService.getExoPlayer(MusicService.java:147)
at com.audiomack.playback.MusicService.onCreate(MusicService.java:232)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4634)
at android.app.ActivityThread.access$1600(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2169)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8587)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
-----------------------------------------------------------------------------------------------------------------------
Stack-trace : 3
-----------------------------------------------------------------------------------------------------------------------
main (native): tid=1 systid=32348
#00 pc 0x5e3e8 libc.so
#01 pc 0x131bb3 libart.so
#02 pc 0x4d409b libart.so
#03 pc 0x4d3f21 libart.so
at android.media.AudioSystem.newAudioSessionId(AudioSystem.java)
at android.media.AudioManager.generateAudioSessionId(AudioManager.java:2567)
at com.google.android.exoplayer2.C.generateAudioSessionIdV21(C.java:1170)
at com.google.android.exoplayer2.SimpleExoPlayer.<init>(SimpleExoPlayer.java:665)
at com.google.android.exoplayer2.SimpleExoPlayer$Builder.build(SimpleExoPlayer.java:558)
at com.audiomack.playback.Players.initExoPlayer(Players.java:60)
at com.audiomack.playback.Players.getSimpleExoPlayerInstance(Players.java:65)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at com.audiomack.playback.MusicService$exoPlayer$2.invoke(MusicService.java:147)
at kotlin.SynchronizedLazyImpl.getValue(SynchronizedLazyImpl.java:74)
at com.audiomack.playback.MusicService.getExoPlayer(MusicService.java:147)
at com.audiomack.playback.MusicService.onCreate(MusicService.java:232)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4661)
at android.app.ActivityThread.access$1700(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2196)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
ch...@google.com <ch...@google.com> #7
In the new stack traces you posted on com.audiomack.playback.MusicService.onCreate
and I assume that this is an Android Service
. That's different from the stack trace of com.audiomack.MainApplication.onCreate()
which I assume is your activity.
Just checking, is the MusicService
running in the foreground, and if not, can you try starting it as such? See
[Deleted User] <[Deleted User]> #8
Yes, it is running as a foreground service, and I have included the code for your convenience.
-----------------------------------------------------------------------------------------------------------------------
onStartCommand - method
-----------------------------------------------------------------------------------------------------------------------
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Timber.tag(TAG).i("onStartCommand called with intent = $intent")
if (intent?.getBooleanExtra(EXTRA_PLAY_WHEN_READY, false) == true) {
playback.reload()
}
sessionToken?.let { token ->
val notification = notificationBuilder.buildNotification(token)
startForeground(NOW_PLAYING_NOTIFICATION, notification)
isForegroundService = true
}
return super.onStartCommand(intent, flags, startId)
}
-----------------------------------------------------------------------------------------------------------------------
However, we are attempting to obtain an instance of Exoplyer at the class level. Which mean, it comes before the startCommand.
private val exoPlayer: SimpleExoPlayer by lazy { Players.getInstance().getSimpleExoPlayerInstance() }
Please tell us on the measures we should take to resolve this issue.
Description
```
fun init(context: Context):
SimpleExoPlayer = INSTANCE
?: SimpleExoPlayer.Builder(context)
.setAudioAttributes(
AudioAttributes.Builder()
.setContentType(C.CONTENT_TYPE_MUSIC)
.setUsage(C.USAGE_MEDIA)
.build(),
true
)
.setHandleAudioBecomingNoisy(true)
.build()
.also { INSTANCE = it }
```
#Stack-trace:
```
main (native): tid=1 systid=29780
#00 pc 0x4b48c libc.so
#01 pc 0x1af92c libart.so
#02 pc 0x669a98 libart.so
#03 pc 0x669888 libart.so
at android.os.BinderProxy.transactNative(Native method)
at android.os.BinderProxy.transact(BinderProxy.java:550)
at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5460)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1626)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1580)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1568)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:668)
at com.google.android.exoplayer2.upstream.DefaultBandwidthMeter$ConnectivityActionReceiver.getInstance(DefaultBandwidthMeter.java:474)
at com.google.android.exoplayer2.upstream.DefaultBandwidthMeter.<init>(DefaultBandwidthMeter.java:312)
at com.google.android.exoplayer2.upstream.DefaultBandwidthMeter.<init>(DefaultBandwidthMeter.java:50)
at com.google.android.exoplayer2.upstream.DefaultBandwidthMeter$Builder.build(DefaultBandwidthMeter.java:207)
at com.google.android.exoplayer2.upstream.DefaultBandwidthMeter.getSingletonInstance(DefaultBandwidthMeter.java:257)
at com.google.android.exoplayer2.SimpleExoPlayer$Builder.<init>(SimpleExoPlayer.java:209)
at com.google.android.exoplayer2.SimpleExoPlayer$Builder.<init>(SimpleExoPlayer.java:161)
at com.audiomack.playback.SimpleExoPlayerImpl.init(SimpleExoPlayerImpl.kt:15)
at com.audiomack.MainApplication.onCreate(MainApplication.kt:82)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6738)
at android.app.ActivityThread.access$1300(ActivityThread.java:238)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1914)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7705)
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)
```
#Step to reproduce:
1. Install the application
2. Run the application
#Version:
OS: 11 (99%), 12(rest)
Device: Samsung(A12, A10), HMD Global(nokia 1.3, 2.4), Techno, Infinix, Moto
#Application