Status Update
Comments
mi...@sharesies.co.nz <mi...@sharesies.co.nz> #2
First of all thanks for this detailed issue.
This issue had been investigated thoroughly when it was first reported internally. The surprising detail in this report is that the issue is not reproducible before 1.7
. I will look into this.
The main problem with POBox is the fact that it is deprecated. Since 2021 Sony has been shipping new Xperia devices with Gboard pre-installed. Although we are aware that there is still a considerable amount of users still using POBox, the described behavior is caused by POBox's noncompliant behavior with InputConnection
and InputMethodManager
documentation. However, this is understandable since TextView
implementation was also not respecting the behavior that is expected from Editors.
Ultimately we have decided to enforce the documented behavior with specifically regards to when editors should call InputMethodManager.updateSelection
. Also, although unconfirmed, there were traces of possible custom code being included in Sony OEM images that changed how InputMethodManager was notified from TextView. If POBox also depended on something like this, it would be impossible for Compose code to replicate the same unknown behavior.
sh...@gmail.com <sh...@gmail.com> #3
sh...@gmail.com <sh...@gmail.com> #4
Just to be sure, it is dangerous to replace Compose TextField with Android View EditText as a workaround for this issue.
Compose 1.7 has a bug that causes ANR when the focus is on EditText.
Another View-related bug in Compose 1.7 is that an Android View is focused by calling FocusManager.clearFocus().
Perhaps there is a lack of testing of Compose 1.7 in combination with Android View. There is also a possibility that there are other fatal bugs related to View.
In other words, the only options for apps targeting the Japanese market that require POBox support are to continue using Compose 1.6 or to use EditText in combination with various workarounds.
[Deleted User] <[Deleted User]> #5
Project: platform/frameworks/support
Branch: androidx-main
Author: Halil Ozercan <
Link:
Fix POBox keyboard issue
Expand for full commit details
Fix POBox keyboard issue
Fix: 373743376
Fix: 329209241
Test: NullableInputConnectionWrapperTest
Change-Id: I94e0e598274fb88b255f977f9fbd50dfbbb1ecb1
Files:
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/text/input/NullableInputConnectionWrapperTest.kt
- M
compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/NullableInputConnectionWrapper.android.kt
Hash: 57f58c4b80d5d8470b2aca325dfdcd55f235231e
Date: Thu Oct 24 01:25:20 2024
ar...@dicoding.com <ar...@dicoding.com> #6
Many thanks again for this report. Especially for giving us a huge clue in terms of what could be going wrong. The fix is now merged and I will ask for a cherry-pick into a stable release.
wa...@gmail.com <wa...@gmail.com> #7
Do you have any concrete plan to cherry-pick the fix into current stable version (1.7.x)? We are currently waiting it.
al...@gmail.com <al...@gmail.com> #8
Yes, this fix is planned to be included in a future 1.7.x
release.
ak...@gmail.com <ak...@gmail.com> #9
Thanks for the fix. Sorry to follow up on this. is it possible for you to share specific release version/date for the stable version? We are waiting on this to decide on our direction.
ya...@gmail.com <ya...@gmail.com> #10
Same problem on API 22 emulator when I load the image placeholder for Coil in the lazy grid, it throws OutOfMemoryError
in some point:
I/art ( 2571): Clamp target GC heap from 387MB to 384MB
I/art ( 2571): Alloc concurrent mark sweep GC freed 4848(222KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 383MB/384MB, paused 270us total 21.225ms
E/art ( 2571): Throwing OutOfMemoryError "Failed to allocate a 6350412 byte allocation with 227524 free bytes and 222KB until OOM"
I/art ( 2571): WaitForGcToComplete blocked for 28.530ms for cause Alloc
D/skia ( 2571): --- allocation failed for scaled bitmap
D/AndroidRuntime( 2571): Shutting down VM
--------- beginning of crash
E/AndroidRuntime( 2571): FATAL EXCEPTION: main
E/AndroidRuntime( 2571): Process: org.proninyaroslav.opencomicvine, PID: 2571
E/AndroidRuntime( 2571): java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
E/AndroidRuntime( 2571): at androidx.compose.ui.res.PainterResources_androidKt.loadImageBitmapResource(PainterResources.android.kt:111)
E/AndroidRuntime( 2571): at androidx.compose.ui.res.PainterResources_androidKt.access$loadImageBitmapResource(PainterResources.android.kt:1)
E/AndroidRuntime( 2571): at androidx.compose.ui.res.PainterResources_androidKt.painterResource(PainterResources.android.kt:70)
E/AndroidRuntime( 2571): at org.proninyaroslav.opencomicvine.ui.components.CharacterCardKt.InnerCharacterCard(CharacterCard.kt:49)
E/AndroidRuntime( 2571): at org.proninyaroslav.opencomicvine.ui.components.CharacterCardKt.CharacterCard(CharacterCard.kt:26)
E/AndroidRuntime( 2571): at org.proninyaroslav.opencomicvine.ui.wiki.characters.CharactersPageKt$CharactersPage$8$2$3$2.invoke(CharactersPage.kt:205)
E/AndroidRuntime( 2571): at org.proninyaroslav.opencomicvine.ui.wiki.characters.CharactersPageKt$CharactersPage$8$2$3$2.invoke(CharactersPage.kt:203)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.grid.ComposableSingletons$LazyGridItemProviderKt$lambda-1$1.invoke(LazyGridItemProvider.kt:88)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.grid.ComposableSingletons$LazyGridItemProviderKt$lambda-1$1.invoke(LazyGridItemProvider.kt:87)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.DefaultLazyLayoutItemsProvider.Item(LazyLayoutItemProvider.kt:118)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.grid.LazyGridItemProviderImpl.Item(LazyGridItemProvider.kt)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.DefaultDelegatingLazyLayoutItemProvider.Item(LazyLayoutItemProvider.kt:197)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.grid.LazyGridItemProviderKt$rememberLazyGridItemProvider$1$1.Item(LazyGridItemProvider.kt)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1$1.invoke(LazyLayoutItemContentFactory.kt:99)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1$1.invoke(LazyLayoutItemContentFactory.kt:98)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
E/AndroidRuntime( 2571): at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
E/AndroidRuntime( 2571): at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.SaveableStateProvider(LazySaveableStateHolder.kt:84)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:98)
E/AndroidRuntime( 2571): at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:90)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
E/AndroidRuntime( 2571): at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:771)
E/AndroidRuntime( 2571): at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:448)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
E/AndroidRuntime( 2571): at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
E/AndroidRuntime( 2571): at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
E/AndroidRuntime( 2571): at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3248)
E/AndroidRuntime( 2571): at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer
ed...@gmail.com <ed...@gmail.com> #11
al...@gmail.com <al...@gmail.com> #12
az...@gmail.com <az...@gmail.com> #13
ur...@gmail.com <ur...@gmail.com> #14
This happens for the preview
java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
at androidx.compose.ui.res.PainterResources_androidKt.loadVectorResource(PainterResources.android.kt:94)
at androidx.compose.ui.res.PainterResources_androidKt.painterResource(PainterResources.android.kt:65)
at com.worldline.paynow.home.PayNowDrawerKt$NavItem$1.invoke(PayNowDrawer.kt:57)
at com.worldline.paynow.home.PayNowDrawerKt$NavItem$1.invoke(PayNowDrawer.kt:47)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.material3.CardKt$Card$1.invoke(Card.kt:806)
at androidx.compose.material3.CardKt$Card$1.invoke(Card.kt:92)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:129)
at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:113)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.SurfaceKt.Surface-T9BRK9s(Surface.kt:110)
at androidx.compose.material3.CardKt.Card(Card.kt:84)
at com.worldline.paynow.home.PayNowDrawerKt.NavItem(PayNowDrawer.kt:47)
at com.worldline.paynow.home.PayNowDrawerKt.PayNowDrawer(PayNowDrawer.kt:40)
at com.worldline.paynow.home.ComposableSingletons$MainActivityKt$lambda-7$1.invoke(MainActivity.kt:75)
at com.worldline.paynow.home.ComposableSingletons$MainActivityKt$lambda-7$1.invoke(MainActivity.kt:74)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.TextKt.ProvideTextStyle(Text.kt:261)
at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:73)
at com.worldline.paynow.ui.theme.ThemeKt.ComposeTemplateTheme(Theme.kt:63)
at com.worldline.paynow.home.MainActivityKt.PayNowDrawerPreview(MainActivity.kt:74)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at androidx.compose.ui.tooling.ComposableInvoker.invokeComposableMethod(ComposableInvoker.kt:155)
at androidx.compose.ui.tooling.ComposableInvoker.invokeComposable(ComposableInvoker.kt:195)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:711)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:709)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:746)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:704)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.tooling.InspectableKt.Inspectable(Inspectable.kt:61)
at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:651)
at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:650)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.tooling.ComposeViewAdapter.WrapPreview(ComposeViewAdapter.kt:645)
at androidx.compose.ui.tooling.ComposeViewAdapter.access$WrapPreview(ComposeViewAdapter.kt:135)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:704)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:701)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:404)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:250)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:249)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:177)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:157)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:156)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:156)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3248)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3238)
at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3238)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3173)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:950)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1060)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:182)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:202)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1147)
at android.view.View.dispatchAttachedToWindow(View.java:20753)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:58)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:366)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
na...@gmail.com <na...@gmail.com> #15
The issue seems not like a issue for tiramisu.
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.