PhotoEditor
PhotoEditor copied to clipboard
App is crashing when using Filter effects in recycler view
I'm using an image from device storage and applying 24 filters of this library to the every position of recycler view. I want to show every filter effect in recycler view with user image. But app is crashing..
E/AndroidRuntime: FATAL EXCEPTION: GLThread 27601 Process: com.xzama.tattoophotoeditorpro, PID: 1775 java.lang.RuntimeException: glUseProgram: glError 1281 at ja.burhanrashid52.photoeditor.GLToolbox.checkGlError(GLToolbox.java:71) at ja.burhanrashid52.photoeditor.TextureRenderer.renderTexture(TextureRenderer.java:111) at ja.burhanrashid52.photoeditor.ImageFilterView.renderResult(ImageFilterView.java:272) at ja.burhanrashid52.photoeditor.ImageFilterView.onDrawFrame(ImageFilterView.java:102) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262)
Yes, This is a known issue #48 . Currently not able to identify the fix. Happy to see a PR on this.
I am facing the same issue rn. Any hack for it till a fix comes visiting?
I found a solution.
Wrap as much filter-views you want in a LinearLayout
and wrap the Linear layout in a HorizontalScrollView
.
Then in Code set the filter to each view. (It's pretty a manual way, but it works)
`<HorizontalScrollView
android:id="@+id/filters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:elevation="20dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter1"
android:layout_width="100dp"
android:layout_height="140dp"
app:photo_src="@drawable/filter_image1"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter2"
android:layout_width="100dp"
android:layout_height="140dp"
app:photo_src="@drawable/filter_image1"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter3"
android:layout_width="100dp"
android:layout_height="140dp"
app:photo_src="@drawable/filter_image1"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter4"
android:layout_width="100dp"
app:photo_src="@drawable/filter_image1"
android:layout_height="140dp"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter5"
android:layout_width="100dp"
app:photo_src="@drawable/filter_image1"
android:layout_height="140dp"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter6"
android:layout_width="100dp"
android:layout_height="140dp"
app:photo_src="@drawable/filter_image1"
android:layout_marginHorizontal="4dp" />
<ja.burhanrashid52.photoeditor.PhotoEditorView
android:id="@+id/filter7"
android:layout_width="100dp"
android:layout_height="140dp"
app:photo_src="@drawable/filter_image1"
android:layout_marginHorizontal="4dp" />
</LinearLayout>
</HorizontalScrollView>`
Wrap as much filter-views you want in a LinearLayout and wrap the Linear layout in a HorizontalScrollView .
It's good that it works for you, but be cautious because this has some performance penalty on scroll compared to RecycleView
, because LinearLayout
render all views regardless it's visible to the screen or not.
Wrap as much filter-views you want in a LinearLayout and wrap the Linear layout in a HorizontalScrollView .
It's good that it works for you, but be cautious because this has some performance penalty on scroll compared to
RecycleView
, becauseLinearLayout
render all views regardless it's visible to the screen or not.
Yes. The libary has issue when views are recycled and effects are reapplied. This is the known issue. That is why in this case, instead of loading the real images, a dummy image of low quality is used in the Horizontal scroll view. Loading all filtered-dummy images (not more than 20 filter) won't cause performance issues). Esp when once loaded it doesn't need to reload.
But it got me thinking, how the sample gif in the libary's readme was made. Was it a previous version?
But it got me thinking, how the sample gif in the libary's readme was made. Was it a previous version?
Which gif are you talking about?