ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Android 12L - AbstractMethodError calling onSpatializerAvailableChanged

Open asos-edgeorge opened this issue 4 years ago • 24 comments

ExoPlayer Version

2.18.0

Devices that reproduce the issue

All devices that have this issue are Samsung devices within the Galaxy Z Fold/Flip series, running Android 12 (presumably 12L)

For example, the three most popular devices experiencing this issue are:

  • Galaxy Z Flip3 5G
  • Galaxy Z Flip4
  • Galaxy Z Fold3 5G

Devices that do not reproduce the issue

Non-Galaxy Z Flip/Fold series devices

Reproducible in the demo app?

Not tested

Reproduction steps

We have seen this issue in the wild and unfortunately do not have access to the affected devices to find steps to reproduce this crash.

Based on the crash reports received, it seems 86% of crashes occur when the app is in the background. Due to the nature of foldable devices, this could be perhaps linked to a form config change (i.e. folding/unfolding) or something similar.

Should it help, our player is defined as follows (with some minor code omitted)

// Cache
val cache = SimpleCache(createVideoCacheDir(context),
                LeastRecentlyUsedCacheEvictor(VIDEO_CACHE_SIZE.toLong()),
                ExoDatabaseProvider(context))

// CacheDataSource
val upstreamFactory: DataSource.Factory = OkHttpDataSourceFactory({ request -> okHttp.newCall(request) }, USER_AGENT)
val cacheDataSource = CacheDataSource.Factory()
                .setCache(exoCache)
                .setUpstreamDataSourceFactory(upstreamFactory)
                .setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)

// ExoPlayer
ExoPlayer.Builder(context)
                .setLooper(Looper.getMainLooper())
                .setMediaSourceFactory(DefaultMediaSourceFactory(cacheDataSource))
                .setTrackSelector(DefaultTrackSelector(context, AdaptiveTrackSelection.Factory()))
                .build()

Expected result

The media plays successfully and backgrounding the app works as expected

Actual result

Exoplayer crashes with the following stacktrace

Fatal Exception: java.lang.AbstractMethodError: abstract method "void android.media.Spatializer$OnSpatializerStateChangedListener.onSpatializerAvailableChanged(android.media.Spatializer, boolean)"
       at android.media.Spatializer$SpatializerInfoDispatcherStub.lambda$dispatchSpatializerAvailableChanged$1$Spatializer$SpatializerInfoDispatcherStub(Spatializer.java:529)
       at android.media.Spatializer$SpatializerInfoDispatcherStub$$ExternalSyntheticLambda0.run(Spatializer.java:6)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Not applicable

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

asos-edgeorge avatar Oct 11 '22 09:10 asos-edgeorge

Thank you for reporting the issue, we will investigate. I'd like to ask some additional information. You mention this occurs only on "Galaxy Z Fold/Flip series, running Android 12 (presumably 12L)". Just to confirm, do you have data if your app is running on other devices with Android 12L/13? For example, Pixel devices have started receiving Android 13. Any errors there?

[added] To avoid the error, you can force ExoPlayer to stop listening to Spatializer changes. On your custom DefaultTrackSelector, you need to set DefaultTrackSelector.Parameters where constrainAudioChannelCountToDeviceCapabilities is disabled. Something like (in java)

DefaultTrackSelector trackSelector = ...
trackSelector.setParameters(
  trackSelector.buildUponParameters().setConstrainAudioChannelCountToDeviceCapabilities(false).build());

That will affect the audio track selection logic and will make the player always play the playable audio track with the highest channel count (which was the behavior before version 2.18). This would affect your app if it is streaming different audio formats (eg stereo and surround formats) and you were relying on ExoPlayer to pick-up stereo or surround audio depending on the Spatializer properties.

christosts avatar Oct 11 '22 11:10 christosts

[internal ref b/252738423]

christosts avatar Oct 11 '22 12:10 christosts

Thanks @christosts for your response

Just to confirm, do you have data if your app is running on other devices with Android 12L/13? For example, Pixel devices have started receiving Android 13. Any errors there?

Based on our crash reports, we are not seeing this for any other device family or Android version. We support all devices running Android 5.0+, so based on that it's a reasonable assumption to say it doesn't look to affect anything else at this time. 

However, should we see any additional devices or OS' in the report, I will update this ticket. 

Going forwards, we will follow the approach you suggest and monitor the results in our crash reports. We should have results to feedback to you in ~2 weeks.

If there's anything else you need from me to help diagnosis, please do let me know here or reach out via email

asos-edgeorge avatar Oct 11 '22 14:10 asos-edgeorge

I'm facing the same issue. See additional information below. Thanks.

ExoPlayer Version

2.18.1

Devices that reproduce the issue

100%Android 12 100% samsung

  • 58% Galaxy Z Flip3 5G
  • 24% Galaxy Z Flip4
  • 5% Galaxy Z Fold4
  • 5% Galaxy Z Fold3 5G
  • 3% Galaxy Z Flip
  • 2% Galaxy Z Flip 5G
  • 2% Galaxy Z Fold2 5G
  • <1% Galaxy Fold 5G
  • <1% Galaxy Tab S7
  • <1% Galaxy Tab S6 Lite
  • <1% Galaxy Z Flip3 5G

Stacktrace

Fatal Exception: java.lang.AbstractMethodError: abstract method "void android.media.Spatializer$OnSpatializerStateChangedListener.onSpatializerAvailableChanged(android.media.Spatializer, boolean)"
       at android.media.Spatializer$SpatializerInfoDispatcherStub.lambda$dispatchSpatializerAvailableChanged$1$Spatializer$SpatializerInfoDispatcherStub(Spatializer.java:529)
       at android.media.Spatializer$SpatializerInfoDispatcherStub$$ExternalSyntheticLambda0.run(Spatializer.java:6)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.os.HandlerThread.run(HandlerThread.java:67)

punxoi avatar Oct 13 '22 06:10 punxoi

@punxoi thank you for the information. May I ask, you mention this occurs 100% on Android 12. Is that Android 12 (API 31) or Android 12L (API 32)? Everything should be on 12L (API 32), but if you've seen any reports in API 31, that would be an interesting data point.

It's unclear yet why this error happens.

christosts avatar Oct 13 '22 09:10 christosts

@asos-edgeorge also on

it seems 86% of crashes occur when the app is in the background

what is the behavior of your app when it's sent to the background? For example, does it continue to play media, does it release the player, anything in between?

christosts avatar Oct 13 '22 18:10 christosts

@christosts 

what is the behavior of your app when it's sent to the background? For example, does it continue to play media, does it release the player, anything in between?

So as far as I can tell, we are calling player.stop(true) which looks to be deprecated

Edit: Should you wish to see a video of this behaviour I would be happy to email it to the address within the Exoplayer Bug Report template

asos-edgeorge avatar Oct 14 '22 21:10 asos-edgeorge

@christosts

@punxoi thank you for the information. May I ask, you mention this occurs 100% on Android 12. Is that Android 12 (API 31) or Android 12L (API 32)? Everything should be on 12L (API 32), but if you've seen any reports in API 31, that would be an interesting data point.

It's unclear yet why this error happens.

Firebase Crashlytics seems to show both 12 and 12L as 12. image image

punxoi avatar Oct 17 '22 01:10 punxoi

@asos-edgeorge @punxoi what is the compileSdkVersion you are are using to build your apk? Specifically, are you using a version before 32 (e.g. 30 or 31)?

christosts avatar Oct 20 '22 11:10 christosts

@christosts I haven't chimed in before, but I see the same crash in our Crashlytics. We currently use compileSdk 31 and targetSdk 30.

Mavamaarten avatar Oct 20 '22 13:10 Mavamaarten

@christosts Same as the above. Compile SDK is 31 and target is 30

asos-edgeorge avatar Oct 20 '22 21:10 asos-edgeorge

@christosts Both compile and target SDK versions are 31.

punxoi avatar Oct 20 '22 23:10 punxoi

image I encountered the same problem. The devices that reported errors in the statistical information on the bugly platform are all Samsung version and Android 12

390057892 avatar Oct 21 '22 05:10 390057892

image I encountered the same problem. The devices that reported errors in the statistical information on the bugly platform are all Samsung version and Android 12 This is my dependent version def exoplayer_version = '2.18.1' implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version" implementation "com.google.android.exoplayer:extension-okhttp:$exoplayer_version"

390057892 avatar Oct 21 '22 05:10 390057892

To solve this issue you need to upgrade your compileSdkVersion to at least 32. This is necessary when you depend on libraries like ExoPlayer that are already compiled against 32. Upgrading the compile SDK should have no influence on the app behaviour, it just makes the latest Android SDK available during compilation and code shrinking.

tonihei avatar Oct 21 '22 07:10 tonihei

Thanks @tonihei - could you perhaps update the documentation to reflect this? I cannot find a reference to this requirement

asos-edgeorge avatar Oct 22 '22 08:10 asos-edgeorge

Well, we weren't fully aware of this either until yesterday. :)

But it definitely seems expected that an app uses at least the compile SDK that all of its dependencies are using. Some dependencies like AndroidX appcompat seem to be able to enforce this automatically, so we'll try to do the same in the future to avoid the additional documentation need.

tonihei avatar Oct 22 '22 09:10 tonihei

Amazing. Thank you for investigating this, in hindsight it seems fairly obvious this is the issue 😅 If you can enforce the version going forwards then that'd certainly help

asos-edgeorge avatar Oct 22 '22 11:10 asos-edgeorge

@tonihei I think Samsung have a bug that they are reporting the device with api level 32 as android os 12 as well. They didn't distinct the android 12 and 12L.

We are facing the same problem here, but both the application compileSdkVersion and targetSdkVersion are 33. At moment, the dev team has not be able to reproduce the issue. We will update this thread when we find more.

zgzong avatar Oct 24 '22 09:10 zgzong

I got this problem too. Is upgrade compileSdkVersion the only way to solve? Won't you do some change to fix?

Thanks.

pft-BohoWu avatar Oct 25 '22 09:10 pft-BohoWu