7

I'm using CameraX to build a camera with with the Preview and Analysis use cases. I've built and run my application locally on an emulator and device. However after I publish to google play I'm getting the following stacktrace reported by crashlytics for one of my users:

Fatal Exception: java.lang.IllegalArgumentException: Can not get supported output size under supported maximum for the format: 34
       at androidx.camera.camera2.impl.SupportedSurfaceCombination.checkSupported(SupportedSurfaceCombination.java)
       at androidx.camera.camera2.impl.SupportedSurfaceCombination.checkSupported(SupportedSurfaceCombination.java)
       at androidx.camera.camera2.impl.Camera2DeviceSurfaceManager.getMaxOutputSize(Camera2DeviceSurfaceManager.java)
       at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java)
       at androidx.camera.core.CameraX.attach(CameraX.java)
       at com.glan.input.fragment.CameraFragment.startCamera(CameraFragment.java) // *** Note this is where I call CameraX.bindToLifecycle(activity, previewUseCase, analysisUseCase)
       at com.glan.input.fragment.CameraFragment.access$000(CameraFragment.java)
       at androidx.fragment.app.Fragment.onActivityCreated(Fragment.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.dispatchPause(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java)
       at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.allocBackStackIndex(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.completeShowHideFragment(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I've looked through the source code for CameraX and what I found is that this error is thrown when none image output size candidates match a given the use case of and image format combo. 34 (the final characters of the error message) is the PRIVATE image format.

I've gone through the source code for both of the use cases that I'm using and it seems that the only formats which can possibly be selected are YUV_420_888 (Preview and Analysis) or JPEG (Analysis).

It's certainly possible I missed something while reading the CameraX code. What can I do to ensure that the PRIVATE image format is never used?

For what it's worth, here's the device information of the device which saw this crash:

Device
Brand: LGE
Model: Nexus 5X
Orientation: Portrait
RAM free: 3.11 GB
Disk free: 554.61 MB

Operating System
Version: 6.0.1
Orientation: Portrait
Rooted: Yes
Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
  • I'm seeing this same crash. Interestingly, it is also from a nexus 5X running Android 6.0.1 and Rooted=Yes. Did you ever find a fix? – gMale May 06 '20 at 21:36
  • unfortunately I haven't. I was on alpha6 (I think) when I got that, newer version of the library might have fixed the problem. – Paymahn Moghadasian May 08 '20 at 18:47

0 Answers0