Closed enterteg closed 4 months ago
Looks like this helps to prevent the crash:
In RTNGiphyGridView.kt
add:
fun onDropViewInstance() {
gridView.children.forEach {
(it as? ViewGroup)?.let { vg ->
vg.removeAllViews()
vg.clearDisappearingChildren()
}
}
gridView.removeAllViews()
gridView.clearDisappearingChildren()
removeAllViews()
}
In RTNGiphyGridViewManager.kt
add:
override fun onDropViewInstance(view: RTNGiphyGridView) {
view.onDropViewInstance()
}
Hey @enterteg,
Thank you for flagging this and for the helpful response!
Indeed, this issue occurs only in React Native, it doesn't happen in the Native Android SDK.
The only solution seems to be overriding onDropViewInstance
, since onDetachedFromWindow
is triggered after the crash occurs. This issue might be related to how React Native handles views, as I've also encountered the crash when trying to use a standard Android recycler view for a list of static texts.
I plan to release a new version with the fix on Monday.
🐛 Bug Report
On Android When I open the new screen with
GiphyGridView
and I start scrolling the list + close the screen - it almost every time crashes the app with the following error:To Reproduce
GiphyGridView
This sometimes also happens when I select one of the gifs and as result just close the screen.
Expected behavior
App should not crash.
Actual Behavior
Fatal error.
Your Environment
3.2.3
0.73.6
Android
Reproducible Demo
Created a minimal reproduction example repo with expo and expo-router (you need to add .env file with proper giphy key to make it work): https://github.com/enterteg/TestGiphy