alexvasilkov / GestureViews

ImageView and FrameLayout with gestures control and position animation
Apache License 2.0
2.38k stars 385 forks source link

Crash on Redmi 6A - GL error from OpenGLRenderer: 0x502 #172

Closed amitav13 closed 2 years ago

amitav13 commented 3 years ago

Hi, I'm getting a crash when trying to show any image with this library with a stacktrace similar to this: https://stackoverflow.com/questions/19739269/gl-error-from-openglrenderer-0x502

There isn't much of an android stacktrace, seems to be coming from the kernel level. This seems to be isolated to this device of mine, but since the images are visible with a regular ImageView, there's likely something within this library that's causing this.

I've tried setting my layer type to software and hardware explicitly as well, no luck.

alexvasilkov commented 3 years ago

Sounds strange. Please post your stacktrace here.

amitav13 commented 3 years ago
2021-06-08 19:36:28.142 18747-19031/app.picturepin.android.dev E/OpenGLRenderer: GL error:  GL_INVALID_OPERATION
2021-06-08 19:36:28.142 18747-19031/app.picturepin.android.dev A/OpenGLRenderer: glEGLImageTargetTexture2DOES error! GL_INVALID_OPERATION (0x502)
2021-06-08 19:36:29.150 18747-19031/app.picturepin.android.dev A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 19031 (RenderThread), pid 18747 (pin.android.dev)
2021-06-08 19:36:29.420 19085-19085/? A/DEBUG: pid: 18747, tid: 19031, name: RenderThread  >>> app.picturepin.android.dev <<<

Note here that these are assert-level logs - which isn't usual for android OS. Seems to be messed at the hardware level or something.

alexvasilkov commented 3 years ago

Not much. Can you share the code that leads to the crash?

amitav13 commented 3 years ago

This is the view settings in kotlin:

imageView.apply {
               //using coil image loading library here
                load(image.uri) {
                    crossfade(true)
                    placeholder(R.drawable.ic_twotone_image_24)
                    transitionName = image.uri.path.toString()
                }
                this.controller.settings
                    .setMaxZoom(4f)
                    .setDoubleTapZoom(-1f) // Falls back to max zoom level
                    .setPanEnabled(true)
                    .setZoomEnabled(true)
                    .setDoubleTapEnabled(true)
                    .setRotationEnabled(false)
                    .setRestrictRotation(false)
                    .setOverscrollDistance(0f, 0f)
                    .setOverzoomFactor(2f)
                    .setFillViewport(false)
                    .setFitMethod(Settings.Fit.INSIDE).gravity = Gravity.CENTER
            }

and the relevant code in XML:

        <com.alexvasilkov.gestures.views.GestureImageView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/img_fullscreen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/_5sdp"
    android:layout_marginBottom="@dimen/_5sdp"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    app:layout_constraintBottom_toTopOf="@+id/img_share"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/img_close"
    tools:src="@tools:sample/avatars" />

I have this image in a viewpager. When I navigate to the screen with the viewpager, the app freezes for ~2sec (the image doesn't show at all), and then crashes. There's nothing else in the logs other than what I've posted above.

alexvasilkov commented 3 years ago

Can you try to load the image without crossfade? Not sure it's the cause, but I hardly have any better suggestion so far.

Does it crash for any image, or only for a particular one? How big is the loaded image?

GestureImageView does not do much, it just sets scale type to "matrix" and then controls the image's matrix according to user's gesture. So there must be something with how this device handles matrix transformations.

Can you also try other image zooming libs, like PhotoView, do they also crash?

alexvasilkov commented 2 years ago

I'll close this issue for now. Let me know if you solved this crash somehow, or feel free to reopen if it still happens.