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

Crash: TextureView doesn't support displaying a background drawable when using with compose #328

Open
Svoka opened this issue May 13, 2024 · 0 comments

Comments

@Svoka
Copy link

Svoka commented May 13, 2024

Description

I receive a TextureView doesn't support displaying a background drawable crash when trying to use Rive with Compose on Android 11

Provide a Repro

AndroidView(
modifier = Modifier,
factory = { context ->
            RiveAnimationView
            .Builder(context)
            .setAutoplay(true)
            .setResource("my_res")
            .build()
},
update = {  }
)

Look like it happen because of a

fun build(): RiveAnimationView {
            return RiveAnimationView(this)
}

which invokes
RiveTextureView(context, attrs),

which invokes
TextureView(context, attrs)

what I dig in my tests that you don't have to pass attrs if they are null, because under the hood the View.java class will try to applied default values which contains background attribute. And will try to it in any case where constructor different from
View(context) callled

So I guess the possible fix is to add another constructor for RiveTextureView (so a call will start something like this)

abstract class RiveTextureView(context: Context) :
    TextureView(context),
    TextureView.SurfaceTextureListener {

Expected behavior

App do not crashed

Device & Versions (please complete the following information)

  • Device: BE2029 OnePlus Nord N10 5G
  • SDK Level [e.g. Android SDK API Level 30]

Additional context

@Svoka Svoka changed the title TextureView doesn't support displaying a background drawable when using with compose Crash: TextureView doesn't support displaying a background drawable when using with compose May 13, 2024
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

No branches or pull requests

1 participant