Status Update
Comments
mi...@sharesies.co.nz <mi...@sharesies.co.nz> #2
This is a particularly hard device to come by - do you happen to have access to the device? If so could you provide us with the output of: adb shell dumpsys media.camera > info.txt
Thanks!
sh...@gmail.com <sh...@gmail.com> #3
sh...@gmail.com <sh...@gmail.com> #4
The issue root cause is that CameraX will default filter out sizes smaller than 640x480. For Preview, the max size will be limited to under display size. I checked the HW spec info for the issue related devices. Display size of FUJITSU F-04J/F-05J is 360x640. That will result int that no size exists in the conditions that is larger or equal to 640x480 and smaller or equal to 360x640.
A temporary workaround for this situation is to use Preview.Builder#setTargetResolution() to set a size smaller than 640x480 to bypass the problem.
For device FUJITSU arrowsM04, I checked its HW spec info and its display size I found is 1280x720. It seems that the problem should not exist in the device.
Could you confirm that the problem exist on arrowsM04 device? What will be the returned value when using Display#getRealSize to obtain the display size?
[Deleted User] <[Deleted User]> #5
> A temporary workaround for this situation is to use Preview.Builder#setTargetResolution() to set a size smaller than 640x480 to bypass the problem.
OK. I will try it.
> Could you confirm that the problem exist on arrowsM04 device?
We receive the crash report (Crashlytics) that this crash has occurred on arrowsM04.
We don't have this device so we can't confirm that the problem really exist on arrowsM04.
> What will be the returned value when using Display#getRealSize to obtain the display size?
We can't investigate it for the same reason.
Thank you.
ar...@dicoding.com <ar...@dicoding.com> #6
This issue happened on devices that the display size is smaller than 640x480. In original auto-resolution mechanism, supported sizes smaller than 640x480 will be default filter out.
The auto-resolution mechanism encodes the guaranteed configurations tables in CameraDevice#createCaptureSession(SessionConfiguration). It defines that the PREVIEW size is the small one of the device display size and 1080p. The PREVIEW size will be the maximal size limitation for Preview use case. The reason it limits the size to display size and 1080p is the stream output in display size or 1080p has been able to provide good enough preview quality. Therefore, auto-resolution mechanism will limit the selected size to be smaller than the small one of the device display size and 1080p.
With above two conditions, in this issue, all sizes smaller than 640x480 have been filter out, therefore, there is no size smaller than the display size 320x240 can be selected to use. And cause the exception.
Solution:
When the display size is smaller than 640x480, auto-resolution mechanism won't filter out those small sizes smaller than 640x480. This makes those small size be left and can be selected for the Preview use case on small display devices.
The solution has been merged and will be included in next CameraX release.
wa...@gmail.com <wa...@gmail.com> #7
Hello.
This crash still occurs.
- CAMERAX VERSION: 1.0.0-beta4
- ANDROID OS BUILD NUMBER: Android 7.1.1
- DEVICE NAME: FUJITSU F-02H
We receive following crash report from FUJITSU F-02H. So far We have received this crash report only from F-02H.
java.lang.IllegalArgumentException
Can not get supported output size under supported maximum for the format: 34
androidx.camera.camera2.internal.SupportedSurfaceCombination.getSupportedOutputSizes (SupportedSurfaceCombination.java:349)
androidx.camera.camera2.internal.SupportedSurfaceCombination.getSuggestedResolutions (SupportedSurfaceCombination.java:197)
androidx.camera.camera2.internal.Camera2DeviceSurfaceManager.getSuggestedResolutions (Camera2DeviceSurfaceManager.java:198)
androidx.camera.core.CameraX.calculateSuggestedResolutions (CameraX.java:949)
androidx.camera.core.CameraX.bindToLifecycle (CameraX.java:351)
androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle (ProcessCameraProvider.java:230)
(our application's package name).CameraFragment.bindCameraUseCases (CameraFragment.java:174)
al...@gmail.com <al...@gmail.com> #8
Could you help to provide the following information to clarify the issue?
1. Is the full name of the device Fujitsu Arrows NX F-02H that has a 1440x2560 display?
2. Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
ak...@gmail.com <ak...@gmail.com> #9
- Is the full name of the device Fujitsu Arrows NX F-02H that has a 1440x2560 display?
Yes
- Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
Since we don't have this device, we'll try to collect this information in the next version of our app. The next version will be released later this month.
ya...@gmail.com <ya...@gmail.com> #10
Hello.
- Please help to provide the supported output sizes of ImageFormat.PRIVATE that is obtained by StreamConfigurationMap#getOutputSizes(int).
We have collected the output of the device where the crash occurs.
Device1
- Model : arrows Be F-05J
- Android Version : 7.1.1
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0: 480x480
CameraId 1: 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
Device2
- Model : Fujitsu arrows M04
- Android Version : 7.1.1
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0: 480x480
CameraId 1: 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
Additional Information
CameraX version : 1.0.0-beta04
We collect the supported output sizes by following code.
val errorString = buildString {
append("The supported output sizes of ImageFormat.PRIVATE: ")
(requireContext().getSystemService(Context.CAMERA_SERVICE) as CameraManager).apply {
cameraIdList.forEachIndexed { index, cameraId ->
val msg = if (VERSION.SDK_INT >= VERSION_CODES.M) {
val configurationMap =
getCameraCharacteristics(cameraId).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
val sizes = configurationMap?.getOutputSizes(ImageFormat.PRIVATE)
"CameraId $index: ${sizes?.joinToString(" ,")}"
} else {
"CameraId $index: This device version is under M."
}
append(msg)
}
}
}
ed...@gmail.com <ed...@gmail.com> #11
al...@gmail.com <al...@gmail.com> #12
I tried to find the device specs and both 720x1280
size display. For the camera id 0 device, it is a different case that the display size is larger than 640x480
but the device only supports a 480x480
size. The case also caused the same IllegalArgumentException and was also fixed by 1.0.0-beta04
release. Before 480x480
size would be filtered out and then caused the IllegalArgumentException. After it was merged, the 640x480
size threshold was removed and then the 480x480
size would be kept and selected to use.
It looks like 1.0.0-beta04
release had been used to collect the supported sizes information. But the issue should have been fixed by 1.0.0-beta04
release. Did you only check the device model name to collect the supported sizes information or collect the information when the IllegalArgumentException issue happens again?
CameraX's 1.0.0-beta04
version. Maybe you can also consider to upgrade to the latest 1.0.0-rc01
version for your application. Thanks.
az...@gmail.com <az...@gmail.com> #13
Did you only check the device model name to collect the supported sizes information or collect the information when the IllegalArgumentException issue happens again?
We collect informations only from the device on which IllegalArgumentException happened.
Our latest app uses CameraX version 1.0.0-beta10
and this issue still occurres.
However we don't receive crash report from Fujitsu arrows Be F-05J
or Fujitsu arrows M04
so far. (This doesn't mean this issue is fixed on these devices because our app is heavily rely on camera so these device's user wouldn't use our app anymore.)
Instead, we receive crash report from
- Model : Fujitsu F-03K
- Android Version : 7.1.2
- Supported output sizes of ImageFormat.PRIVATE
CameraId 0 : 480x480
CameraId 1 : 2048x1536 ,1920x1080 ,1280x720 ,960x720 ,640x480 ,320x240 ,176x144
ur...@gmail.com <ur...@gmail.com> #14
I missed some settings when I simulated the issue by robolectric test so that I was not able to reproduce it. Now, I can reproduce the issue if the device only supports one 480x480 resolution. I'm working on the solution and target to make it included in next release.
na...@gmail.com <na...@gmail.com> #15
Branch: androidx-main
commit 69d15dff7bb857ee33a0f643ff42a0f8bc475ab2
Author: charcoalchen <charcoalchen@google.com>
Date: Fri Jan 08 18:30:03 2021
Fixed IllegalArgumentException issue happened when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480.
Do not filter out sizes smaller than 640x480 when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480.
Relnote:"Fixed IllegalArgumentException issue happened when all preview supported sizes are smaller than 640x480 and display size is larger than 640x480."
Bug: 150506192
Test: SupportedSurfaceCombinationTest
Change-Id: I2a63ce8e2ad42a9cc060c8635ac3603bf440b1ec
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
M camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
as...@box.com <as...@box.com> #16
br...@monzo.com <br...@monzo.com> #17
ja...@gmail.com <ja...@gmail.com> #18
@ #17 yes, I pointed that out in this report a year ago but unfortunately nothing has changed yet.
Instead, I've now copied the painterResource()
code and modified it so that instead of crashing, it logs an error to Crashlytics (through Timber) and shows a grey block as a fallback. I only recently wrote this so I didn't receive any error logs from devices in the field yet. Once I do, I'll finally know the real cause of this crash. In the meantime, at least devices affected by it won't crash anymore!
import android.content.res.Resources
import android.util.TypedValue
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import timber.log.Timber
/**
* Copied from `androidx.compose.ui.res.PainterResources.android.kt`.
*
* Only rasterized image handling is altered, VectorDrawable requests are
* passed through to the original Compose code. See comments inside for modifications.
*/
@Composable
fun fallbackPainterResource(@DrawableRes id: Int): Painter {
val context = LocalContext.current
val res = resources()
val value = remember { TypedValue() }
res.getValue(id, value, true)
val path = value.string
// Assume .xml suffix implies loading a VectorDrawable resource
return if (path?.endsWith(".xml") == true) {
/**
* ***** MODIFIED *****
* Original code:
* val imageVector = loadVectorResource(context.theme, res, id, value.changingConfigurations)
* rememberVectorPainter(imageVector)
*
* Modified code: calls the original painterResource for handling VectorDrawables.
* ***** MODIFIED *****
*/
painterResource(id = id)
} else {
// Otherwise load the bitmap resource
/**
* ***** MODIFIED *****
* Original code: throws throwable.
* Modified code: falls back to showing a gray color when loading image fails.
* ***** MODIFIED *****
*/
val imageBitmap = remember(path, id, context.theme) {
loadImageBitmapResource(res, id)
}
if (imageBitmap != null) {
BitmapPainter(imageBitmap)
} else {
ColorPainter(Color.LightGray)
}
}
}
/**
* Copied from `androidx.compose.ui.res.PainterResources.android.kt`.
*
* ***** MODIFIED *****
* Original code: catches exception, but throws other instead, hiding original cause.
* Modified code: logs original throwable, and returns null.
* ***** MODIFIED *****
*/
private fun loadImageBitmapResource(res: Resources, id: Int): ImageBitmap? {
return try {
ImageBitmap.imageResource(res, id)
} catch (throwable: Throwable) {
Timber.e(throwable, "Failed to load resource $id")
return null
}
}
/**
* Copied from `androidx.compose.ui.res.Resources.android.kt`.
*/
@Composable
@ReadOnlyComposable
private fun resources(): Resources {
LocalConfiguration.current
return LocalContext.current.resources
}
al...@gmail.com <al...@gmail.com> #19
The issue was Out Of Memory and I fixed by replacing the pngs to the drawable-nodpi folder. For some reason the images were being stretched.
ap...@google.com <ap...@google.com> #20
Branch: androidx-main
commit 0232cb448f662706185dd836279f187aa49fb27f
Author: Nader Jawad <njawad@google.com>
Date: Mon May 22 23:12:14 2023
Improved error messaging of painterResource
Updated painterResource implementation to provide
more descriptive error messages and include the
name of the asset that is attempted to be loaded.
Added explicit messaging of webp support.
Relnote: "Add ResourceResolutionException type
to wrap throwables thrown when attempting to load
bitmap assets with a description of the asset path
that failed to load."
Fixes: 230166331
Fixes: 278424788
Test: Added test to verify webp image loading
Change-Id: I19f445605ae8b171532b73b7ae4697cec0453767
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
A compose/foundation/foundation/src/androidAndroidTest/res/drawable-nodpi/webp_test.webp
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PainterResources.android.kt
nj...@google.com <nj...@google.com>
pr...@google.com <pr...@google.com> #21
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.6.0-alpha01
androidx.compose.foundation:foundation-android:1.6.0-alpha01
androidx.compose.ui:ui:1.6.0-alpha01
androidx.compose.ui:ui-android:1.6.0-alpha01
no...@gmail.com <no...@gmail.com> #22
Reproduced on Pixel 4 API 32 emulator. It my case it doesn't work with isShrinkResources = true
FATAL EXCEPTION: main
Process: app.dexvpn, PID: 18745
java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
at app.dexvpn.vm2.j0(SourceFile:1134)
at app.dexvpn.bw2.f(SourceFile:164)
at app.dexvpn.vl0.q(SourceFile:380)
at app.dexvpn.vl0.p(SourceFile:217)
at app.dexvpn.bg5.k0(SourceFile:111)
at app.dexvpn.en0.b(SourceFile:51)
at app.dexvpn.en0.k0(Unknown Source:8)
at app.dexvpn.n33.k0(SourceFile:215)
at app.dexvpn.en0.b(SourceFile:51)
at app.dexvpn.en0.k0(Unknown Source:8)
at app.dexvpn.k23.a(SourceFile:266)
at app.dexvpn.k23.invoke(SourceFile:174)
at app.dexvpn.en0.invoke(SourceFile:59)
at app.dexvpn.bw2.h(SourceFile:182)
at app.dexvpn.xp5.c(SourceFile:185)
at app.dexvpn.q70.K(SourceFile:80)
at app.dexvpn.y33.e(SourceFile:88)
at app.dexvpn.ek2.a(SourceFile:270)
at app.dexvpn.ek2.invoke(SourceFile:258)
at app.dexvpn.en0.invoke(SourceFile:59)
at app.dexvpn.bw2.h(SourceFile:182)
at app.dexvpn.v75.f(SourceFile:115)
at app.dexvpn.r43.f(SourceFile:33)
at app.dexvpn.dp2.i(SourceFile:83)
at app.dexvpn.jf1.b(SourceFile:753)
at app.dexvpn.jf1.invoke(SourceFile:194)
at app.dexvpn.en0.invoke(SourceFile:59)
at app.dexvpn.jf1.b(SourceFile:427)
at app.dexvpn.jf1.invoke(SourceFile:82)
at app.dexvpn.en0.invoke(SourceFile:59)
at app.dexvpn.p31.y(Unknown Source:19)
at app.dexvpn.ip0.p(SourceFile:131)
at app.dexvpn.ip0.i(Unknown Source:13)
at app.dexvpn.xp0.p(SourceFile:18)
at app.dexvpn.ow4.a(SourceFile:31)
at app.dexvpn.wo0.a(SourceFile:10)
at app.dexvpn.wo0.a(SourceFile:10)
at app.dexvpn.wo0.a(SourceFile:10)
at app.dexvpn.wo0.a(SourceFile:10)
at app.dexvpn.wo0.a(SourceFile:10)
at app.dexvpn.xp0.g(Unknown Source:10)
at app.dexvpn.r13.c(SourceFile:102)
at app.dexvpn.m13.v(SourceFile:146)
at app.dexvpn.u23.a(SourceFile:36)
at app.dexvpn.g43.a(SourceFile:17)
at app.dexvpn.c43.invoke(SourceFile:673)
at app.dexvpn.jf1.invoke(SourceFile:179)
at app.dexvpn.o13.f(SourceFile:101)
at app.dexvpn.pl2.c(SourceFile:47)
at app.dexvpn.vb.f(SourceFile:59)
at app.dexvpn.vb.D(SourceFile:632)
at app.dexvpn.p03.g(SourceFile:13)
at app.dexvpn.r03.c(SourceFile:11)
at app.dexvpn.vb.f(SourceFile:20)
at app.dexvpn.vb.D(SourceFile:649)
at app.dexvpn.p03.g(SourceFile:13)
at app.dexvpn.r03.c(SourceFile:11)
at app.dexvpn.tp5.g(SourceFile:6)
at app.dexvpn.r03.c(SourceFile:11)
at app.dexvpn.as1.g(SourceFile:104)
at app.dexvpn.r03.c(SourceFile:11)
at app.dexvpn.e13.a(SourceFile:50)
at app.dexvpn.e13.m(SourceFile:17)
at app.dexvpn.ej1.f(SourceFile:64)
at app.dexvpn.ku5.a(SourceFile:60)
at app.dexvpn.lu5.c(SourceFile:71)
at app.dexvpn.wa4.a(Unknown Source:12)
at app.dexvpn.i13.z0(SourceFile:113)
at app.dexvpn.xi3.c(SourceFile:58)
at app.dexvpn.xi3.j(SourceFile:133)
at app.dexvpn.xi3.d(SourceFile:86)
at app.dexvpn.xi3.d(SourceFile:101)
at app.dexvpn.xi3.d(SourceFile:101)
at app.dexvpn.xi3.d(SourceFile:101)
at androidx.compose.ui.platform.AndroidComposeView.i(Unknown Source:7)
at app.dexvpn.i13.z0(SourceFile:50)
at app.dexvpn.i13.c(SourceFile:124)
at app.dexvpn.mf.f(SourceFile:59)
at app.dexvpn.pl2.c(SourceFile:47)
at app.dexvpn.te.c(SourceFile:27)
at app.dexvpn.te.D(SourceFile:103)
at app.dexvpn.p03.g(SourceFile:13)
at app.dexvpn.r03.c(SourceFile:11)
at app.dexvpn.e13.a(SourceFile:50)
at app.dexvpn.e13.m(SourceFile:17)
at app.dexvpn.ej1.f(SourceFile:64)
at app.dexvpn.ku5.a(SourceFile:60)
at app.dexvpn.lu5.c(SourceFile:71)
at app.dexvpn.wa4.a(Unknown Source:12)
at app.dexvpn.i13.z0(SourceFile:113)
at app.dexvpn.xi3.c(SourceFile:58)
at app.dexvpn.xi3.j(SourceFile:133)
at app.dexvpn.xi3.f(SourceFile:73)
at androidx.compose.ui.platform.AndroidComposeView.q(SourceFile:14)
at app.dexvpn.ua4.a(Unknown Source:3)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(SourceFile:19)
at android.view.View.draw(View.java:22707)
at android.view.View.updateDisplayListIfDirty(View.java:21579)
2023-09-13 18:52:31.152 18745-18745 AndroidRuntime app.dexvpn E at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:534)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:540)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:616)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4488)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4208)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3368)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2173)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8750)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:780)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7798)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
as...@gmail.com <as...@gmail.com> #23
Any possible workaround? 1.6.0 is not stable yet
Description
Issue
Loading the PNG image attached to this post ("missing_picture.png") like this:
... triggers this exception in production on Android 5, 6 and 7 (my minSdk is 21):
The image is actually a PNG, so the error is incorrect. I ran a tool called
pngcheck
on both the source image and the image as it ends up in the APK, but it tells me everything is OK. Also, this PNG works fine on Android 8+.Investigation
Unfortunately, I cannot reproduce it in an emulator. In
PainterResources.android.kt
I see this code:To me, it seems this incorrectly swallows the real exception.