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

java.lang.IllegalArgumentException - nativePtr is null #381

Closed
spectrl opened this issue Nov 1, 2024 · 2 comments · Fixed by #382
Closed

java.lang.IllegalArgumentException - nativePtr is null #381

spectrl opened this issue Nov 1, 2024 · 2 comments · Fixed by #382

Comments

@spectrl
Copy link

spectrl commented Nov 1, 2024

Information

  • Haze version: 0.9.0-rc02
  • Platform: Android
  • Platform version: Android 14

Behavior

Just updated from 0.9.0-beta01 to 0.9.0-rc02 and have started seeing crashes in the wild once I published a new app release. Works fine on my Pixel 8 device but have seen crashes on a Galaxy A15 5G and IQOO Z7x 5G (plus others).

Note that I didn't have any issues at all with 0.9.0-beta01.

Didn't change any of my implementation after the update either, other than what was required for the breaking API changes – which was just updating the style param in my case.

Stack trace:

Fatal Exception: java.lang.IllegalArgumentException: nativePtr is null
       at libcore.util.NativeAllocationRegistry.registerNativeAllocation(NativeAllocationRegistry.java:264)
       at android.graphics.RenderEffect.<init>(RenderEffect.java:314)
       at android.graphics.RenderEffect.createBlurEffect(RenderEffect.java:117)
       at dev.chrisbanes.haze.RenderEffect_androidKt.createRenderEffect-nhveHWw(RenderEffect_android.kt:71)
       at dev.chrisbanes.haze.RenderEffect_androidKt.createRenderEffect-nhveHWw$default(RenderEffect_android.kt:36)
       at dev.chrisbanes.haze.HazeChildNode.updateRenderEffectIfDirty(HazeChildNode.kt:375)
       at dev.chrisbanes.haze.HazeChildNode.drawEffectWithGraphicsLayer(HazeChildNode.kt:333)
       at dev.chrisbanes.haze.HazeChildNode.draw(HazeChildNode.kt:273)
       at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-eZhPAX0$ui_release(LayoutNodeDrawScope.kt:110)
       at androidx.compose.ui.node.LayoutNodeDrawScope.draw-eZhPAX0$ui_release(LayoutNodeDrawScope.kt:89)
       at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:450)
       at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:439)
       ...
@chrisbanes
Copy link
Owner

chrisbanes commented Nov 2, 2024

You’re going to need to share some code. What style are you using? etc

It seems like those devices don’t like the blurRadius value that you’re using.

@spectrl
Copy link
Author

spectrl commented Nov 2, 2024

Here's how I'm using it:

    val hazeState = remember { HazeState() }
    Surface(
        modifier = modifier.aspectRatio(1f),
        ...
    ) {
        displayData.backgroundImage?.let {
            RemoteImage(
                url = it.url,
                contentScale = ContentScale.Crop,
                modifier = Modifier
                    .fillMaxSize()
                    .haze(hazeState),
            )
        }
        Box(
            modifier = Modifier
                .clickable { displayData.link?.url?.let { onClick(it) } }
                .fillMaxSize()
                .hazeChild(
                    state = hazeState,
                    style = HazeDefaults.style(
                        backgroundColor = backgroundColor,
                        tint = tint(tint),
                        blurRadius = if (displayData.hasBackgroundImage) 2.dp else 0.dp,
                        noiseFactor = 0f,
                    ),
                ),
        ) {
        ...
        }
    }

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 a pull request may close this issue.

2 participants