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

Add project to test resource loading issue. #707

Closed

Conversation

geoff-powell
Copy link
Collaborator

@geoff-powell geoff-powell commented Jan 28, 2023

Attempt to reproduce and fix font and resource loading issue on linux. See sample stacktraces below:

 java.lang.NullPointerException
        at android.graphics.fonts.Font_Builder_Delegate.createBuffer(Font_Builder_Delegate.java:52)
        at android.graphics.fonts.Font$Builder.createBuffer(Font.java:264)
        at android.graphics.fonts.Font$Builder.<init>(Font.java:200)
        at android.graphics.Typeface$Builder.<init>(Typeface.java:517)
        at android.graphics.Typeface_Delegate.createFromDisk(Typeface_Delegate.java:91)
        at com.android.layoutlib.bridge.impl.ResourceHelper.getFont(ResourceHelper.java:495)
        at com.android.layoutlib.bridge.impl.ResourceHelper.getFont(ResourceHelper.java:507)
        at android.content.res.Resources_Delegate.getFont(Resources_Delegate.java:876)
        at android.content.res.Resources.getFont(Resources.java:469)
        at app.cash.paparazzi.internal.ResourcesInterceptor.intercept(ResourcesInterceptor.kt:12)
        at androidx.core.content.res.ResourcesCompat.getFont(ResourcesCompat.java)
        at com.squareup.util.android.widget.ContextsKt.getFont(Contexts.kt:23)
....
java.lang.IllegalStateException: Could not load font
    	at androidx.compose.ui.text.font.TypefaceRequestCache.runCached(FontFamilyResolver.kt:205)
    	at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve(FontFamilyResolver.kt:94)
    	at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve-DPcqOEQ(FontFamilyResolver.kt:81)
    	at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke-DPcqOEQ(AndroidParagraphIntrinsics.android.kt:79)
    	at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke(AndroidParagraphIntrinsics.android.kt:77)
    	at androidx.compose.ui.text.platform.extensions.TextPaintExtensions_androidKt.applySpanStyle(TextPaintExtensions.android.kt:63)
    	at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics.<init>(AndroidParagraphIntrinsics.android.kt:90)
    	at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics_androidKt.ActualParagraphIntrinsics(AndroidParagraphIntrinsics.android.kt:154)
    	at androidx.compose.ui.text.ParagraphIntrinsicsKt.ParagraphIntrinsics(ParagraphIntrinsics.kt:98)
    	at androidx.compose.ui.text.MultiParagraphIntrinsics.<init>(MultiParagraphIntrinsics.kt:102)
    	at androidx.compose.foundation.text.TextDelegate.layoutIntrinsics(TextDelegate.kt:131)
    	at androidx.compose.foundation.text.TextDelegate.layoutText-K40F9xA(TextDelegate.kt:155)
    	at androidx.compose.foundation.text.TextDelegate.layout-NN6Ew-U(TextDelegate.kt:242)
....
java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
        at androidx.compose.ui.res.PainterResources_androidKt.loadImageBitmapResource(PainterResources.android.kt:111)
        at androidx.compose.ui.res.PainterResources_androidKt.access$loadImageBitmapResource(PainterResources.android.kt:1)
        at androidx.compose.ui.res.PainterResources_androidKt.painterResource(PainterResources.android.kt:70)
        at com.squareup.cash.mooncake.compose_ui.components.ToolbarKt$NavigateUpButton$2.invoke(Toolbar.kt:221)
        at com.squareup.cash.mooncake.compose_ui.components.ToolbarKt$NavigateUpButton$2.invoke(Toolbar.kt:219)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at com.squareup.cash.mooncake.compose_ui.components.IconButtonKt.IconButton(IconButton.kt:39)
...

@geoff-powell geoff-powell force-pushed the gpowell/repro-font-resource-loading-issue branch from 5a8aead to eeedb74 Compare January 28, 2023 14:41
@mohsin-motorway
Copy link

We have been receiving resource not found exception on images and fonts specifically when calling paparazzi test functions in our library test from composable in feature modules... is this PR a fix for the same solution?
Here is a brief exception log;
java.lang.IllegalStateException: Could not load font at androidx.compose.ui.text.font.TypefaceRequestCache.runCached(FontFamilyResolver.kt:205) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve(FontFamilyResolver.kt:94) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve-DPcqOEQ(FontFamilyResolver.kt:81) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke-DPcqOEQ(AndroidParagraphIntrinsics.android.kt:79) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke(AndroidParagraphIntrinsics.android.kt:77) at androidx.compose.ui.text.platform.extensions.TextPaintExtensions_androidKt.applySpanStyle(TextPaintExtensions.android.kt:55) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics.<init>(AndroidParagraphIntrinsics.android.kt:90) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics_androidKt.ActualParagraphIntrinsics(AndroidParagraphIntrinsics.android.kt:154) at androidx.compose.ui.text.ParagraphIntrinsicsKt.ParagraphIntrinsics(ParagraphIntrinsics.kt:98) at androidx.compose.ui.text.MultiParagraphIntrinsics.<init>(MultiParagraphIntrinsics.kt:102)

@geoff-powell
Copy link
Collaborator Author

geoff-powell commented Jan 30, 2023

We have been receiving resource not found exception on images and fonts specifically when calling paparazzi test functions in our library test from composable in feature modules... is this PR a fix for the same solution?
Here is a brief exception log;
java.lang.IllegalStateException: Could not load font at androidx.compose.ui.text.font.TypefaceRequestCache.runCached(FontFamilyResolver.kt:205) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve(FontFamilyResolver.kt:94) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve-DPcqOEQ(FontFamilyResolver.kt:81) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke-DPcqOEQ(AndroidParagraphIntrinsics.android.kt:79) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics$resolveTypeface$1.invoke(AndroidParagraphIntrinsics.android.kt:77) at androidx.compose.ui.text.platform.extensions.TextPaintExtensions_androidKt.applySpanStyle(TextPaintExtensions.android.kt:55) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics.<init>(AndroidParagraphIntrinsics.android.kt:90) at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics_androidKt.ActualParagraphIntrinsics(AndroidParagraphIntrinsics.android.kt:154) at androidx.compose.ui.text.ParagraphIntrinsicsKt.ParagraphIntrinsics(ParagraphIntrinsics.kt:98) at androidx.compose.ui.text.MultiParagraphIntrinsics.<init>(MultiParagraphIntrinsics.kt:102)

@mohsin-motorway
👋🏽 hmm looking at your stacktrace, you may be having a similar issue I'm trying to reproduce. We are only seeing it happen on CI on linux (amd64 arch) and can't reproduce it on Mac OS (arm64 arch). Do you mind filing an issue on the repro with a sample reproducing the issue. Would help a ton to diagnose the issue and get a fix in 👍🏽

Curious, what environment are you seeing this issue arise?

@geoff-powell geoff-powell force-pushed the gpowell/repro-font-resource-loading-issue branch from eeedb74 to f3f3bdd Compare January 30, 2023 13:16
@geoff-powell geoff-powell force-pushed the gpowell/repro-font-resource-loading-issue branch from f3f3bdd to 43ee3fa Compare January 30, 2023 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants