react-native-blur: App crash in android when used more then 1 BluerView in same component

Bug report

Summary

Android app crashes when used multiple blurView in one component. One BlurView in component is working fine.

Environment info

react-native info output:

System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
    Memory: 71.70 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.2.0 - /usr/local/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.13.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 27, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_222 - /usr/bin/javac
    Python: 3.7.4 - /Users/mac/opt/anaconda3/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 3.6.0

Steps to reproduce

  1. Install library as explained in docs
  2. Use 2 or more BlurView in same component

Reproducible sample code

<BlurView blurType={'light'} style={styles.blurContainer}>
  <Text style={styles.imageTitle}>BlurView One</Text>
</BlurView>
<BlurView blurType={'light'} style={styles.blurContainer}>
  <Text style={styles.imageTitle}>BlurView Two</Text>
</BlurView>

ADB Logcat Shows

07-09 21:55:44.181 15218 15218 D AndroidRuntime: Shutting down VM
07-09 21:55:44.183 15218 15218 E AndroidRuntime: FATAL EXCEPTION: main
07-09 21:55:44.183 15218 15218 E AndroidRuntime: Process: com.myapp, PID: XXXXX
07-09 21:55:44.183 15218 15218 E AndroidRuntime: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at java.util.ArrayList.get(ArrayList.java:437)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.getAndVerifyPreorderedView(ViewGroup.java:3659)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4147)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21439)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21310)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21439)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21310)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21439)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21310)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.views.view.ReactViewGroup.dispatchDraw(ReactViewGroup.java:703)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at com.facebook.react.ReactRootView.dispatchDraw(ReactRootView.java:232)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21308)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at android.view.View.draw(View.java:21439)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at eightbitlab.com.blurview.BlockingBlurController.updateBlur(BlockingBlurController.java:149)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at eightbitlab.com.blurview.BlockingBlurController.draw(BlockingBlurController.java:225)
07-09 21:55:44.183 15218 15218 E AndroidRuntime: 	at eightbitlab.com.blurview.BlurView.draw(BlurView.java:51)
...

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 14
  • Comments: 20

Commits related to this issue

Most upvoted comments

Just FI

android/app/build.gradle

dependencies {
    .......
    implementation('com.eightbitlab:blurview:1.6.6') {
        force = true
    }
}

I’m only using 1 BlurView and this crash occurs. It’s not related to multiple BlurViews.

same thing with flatlist render items if there is only 1 item it works, otherwise it crashed

still got this crash, so sad

I’m only using 1 BlurView and this crash occurs. It’s not related to multiple BlurViews.

Adding to this, I have validated (and I believe it’s something simple to test) that you can have two BlurViews on a single component and not have any crashes.

In my short experience debugging this (which resulted in dropping the library for Android and implementing a workaround using WebView and CSS Blur filters) and looking at the other open issues in the library, these crashes could be related to animations and transitions (for example using inside an Animated.View or in conjunction with React Navigation JS transitions) predating on the same resources that BlurView requires.

This seems a really intensive process for Android and the implementation of the native BlurView library by Dimezis could be too naive for it to work in production environments, since the Blur is performed on the main thread.

But I honestly don’t have the knowledge of native Android development to produce a more insightful comment, just hope this points someone in the right direction.

Same here. Can’t use BlurView as FlatList item…

I can confirm this bug with a different code path. I am using the BlurView as background in a react-navigation modal navigation screen. When using navigation.replace to open another modal (which also renders a blur view) the app crashes with the same logcat output.

Same here.