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

Query for supported sample rates for FLAC encoder crashes on some Android 9 devices #628

Closed
chenxiaolong opened this issue Nov 11, 2024 · 3 comments · Fixed by #629 or #630
Closed
Assignees
Labels
bug/limitation elsewhere Bug/limitation in the ROM or another project

Comments

@chenxiaolong
Copy link
Owner

(Reported to me via email)

11-10 16:28:06.762 14109 14109 D AndroidRuntime: Shutting down VM
11-10 16:28:06.763 14109 14109 E AndroidRuntime: FATAL EXCEPTION: main
11-10 16:28:06.763 14109 14109 E AndroidRuntime: Process: com.chiller3.bcr, PID: 14109
11-10 16:28:06.763 14109 14109 E AndroidRuntime: java.lang.ExceptionInInitializerError
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.chiller3.bcr.RecorderApplication.onCreate(Unknown Source:269)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6245)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.app.ActivityThread.access$1200(ActivityThread.java:238)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1787)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7073)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to get length of null array
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at android.media.MediaCodecInfo$AudioCapabilities.getSupportedSampleRates(MediaCodecInfo.java:973)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at androidx.core.math.MathUtils.fromCodec-Qn1smSk(Unknown Source:58)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.chiller3.bcr.format.FlacFormat.<init>(Unknown Source:31)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.chiller3.bcr.format.Format$Companion$all$2$3.invoke(Unknown Source:2)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.chiller3.bcr.format.Format$$ExternalSyntheticLambda0.invoke(Unknown Source:53)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at kotlin.SynchronizedLazyImpl.getValue(Unknown Source:20)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	at com.chiller3.bcr.format.Format.<clinit>(Unknown Source:13)
11-10 16:28:06.763 14109 14109 E AndroidRuntime: 	... 11 more

This was already fixed 6 years ago in AOSP, but some OEMs are terrible at pulling in fixes: https://android.googlesource.com/platform/frameworks/base/+/2e961480fe0f4e87f2b7f621b276035864124f69%5E%21/

We can hackily work around this by catch the NullPointerException.

@chenxiaolong
Copy link
Owner Author

Test build: BCR-1.73.r5.g8d41572-release.zip

@chenxiaolong
Copy link
Owner Author

chenxiaolong commented Nov 12, 2024

Next crash:

11-12 16:47:56.466  8304  8304 W om.chiller3.bc: Accessing hidden field Landroid/media/AudioFormat;->SAMPLE_RATE_HZ_MIN:I (dark greylist, reflection)
...
11-12 16:47:56.467  8304  8304 E AndroidRuntime: Caused by: java.lang.NoSuchFieldException: No field SAMPLE_RATE_HZ_MIN in class Landroid/media/AudioFormat; (declaration of 'android.media.AudioFormat' appears in /system/framework/framework.jar)
11-12 16:47:56.467  8304  8304 E AndroidRuntime: 	at java.lang.Class.getDeclaredField(Native Method)
11-12 16:47:56.467  8304  8304 E AndroidRuntime: 	at com.chiller3.bcr.extension.AudioFormatExtensionsKt.<clinit>(Unknown Source:4)
11-12 16:47:56.467  8304  8304 E AndroidRuntime: 	... 30 more

The ancient Android version is also missing https://android.googlesource.com/platform/frameworks/base/+/ca6f81d39525174e926c2fcc824fe9531ffb3563%5E%21/ so

android:usesNonSdkApi="true"
doesn't work.

@chenxiaolong
Copy link
Owner Author

Test build for #630: BCR-1.73.r7.g7611d52-release.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/limitation elsewhere Bug/limitation in the ROM or another project
Projects
None yet
1 participant