react-native-blur
react-native-blur copied to clipboard
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
- Install library as explained in docs
- 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)
...
Same here.
1+
It's a request to support please resolve this issue ASAP. Thank you!
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 thing with flatlist render items if there is only 1 item it works, otherwise it crashed
same thing with flatlist render items if there is only 1 item it works, otherwise it crashed
There is no issue with flatlist, if you simply add 2 blur views on same component, it will crash or render white area instead of blur.
Hit this too. Surprised when I found the root cause.
Hi I am getting is issue as well. I am rendering a list of card using flatlist. In the card component I am making a Text value blur for every card. But when i scroll App crashes. Can anybody please help.
Hi I am getting is issue as well. I am rendering a list of card using flatlist. In the card component I am making a Text value blur for every card. But when i scroll App crashes. Can anybody please help.
I tried simple hack. In my case I had number of cards in list. On each card there was a text with background blur. I took image background of same height & width for blur area I want and give blurRadius to image to create blur effect. But if you have multi line text then you need to break down that text into lines and then set image background for each line with blurRadius property. You can provide some more details of your case. It will be easier to figure out solution.
But still hoping to get this issue resolved in Library. 😌
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.
I have a similar issue and found that disabling animations for the StackNavigator or the Screen prevents the crash (but you lose the nice transitions):
<Stack.Navigator
screenOptions={{
animationEnabled: false
}}
>
I believe this issue is also related to https://github.com/react-native-community/react-native-blur/issues/389.
Same here. Can't use BlurView as FlatList item..
I'm only using 1 BlurView and this crash occurs. It's not related to multiple BlurViews.
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.
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.
Thank you. That part about React Navigation animations helped me to resolve my problem. I just disabled React Navigation animations on screens that use BlurView and it worked as expected.
Just FI
android/app/build.gradle
dependencies {
.......
implementation('com.eightbitlab:blurview:1.6.6') {
force = true
}
}
Just FI
android/app/build.gradle
dependencies { ....... implementation('com.eightbitlab:blurview:1.6.6') { force = true } }
Confirmed , this solution works
This is still buggy. I've applied BlurView to @react-navigation/bottom-tabs in order to have a transparent blur bottom bar and the designs worked fine, but the app crashes every time the app is reloaded.
inside screenOptions on Tab.Navigator:
tabBarBackground: () => (
<View style={styles.blurContainer}>
<BlurView
style={styles.tabBar}
blurType="light"
blurAmount={5}
overlayColor="transparent"
/>
</View>
),
UPDATE: If anyone is trying to do the same as me (render a blurry tab bar navigation on React Native) you gotta verify first if it is rendered with useRef(), otherwise it will crash every first render.
Mencioned by @ndbroadbent in #194 , do something like this:
.
.
.
import React, {useRef} from 'react';
const menuBarRef = useRef(null);
<Tab.Navigator
screenOptions={{
tabBarBackground: () => (
<View ref={menuBarRef} style={styles.blurContainer}>
{menuBarRef?.current === null ? null : (
<BlurView
style={styles.tabBar}
blurType="light"
blurAmount={5}
overlayColor="transparent"
/>
)}
</View>
),
.
.
.
still got this crash, so sad
https://github.com/Kureev/react-native-blur/issues/384#issuecomment-950824345
this produces
` FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:checkStagingDebugAarMetadata'.
Could not resolve all files for configuration ':app:stagingDebugRuntimeClasspath'. Could not find com.eightbitlab:blurview:1.6.6. Searched in the following locations:`
for me, how would I install that implementation?
це виробляє
` ПОМИЛКА: Помилка збірки за винятком.
- Що пішло не так: не вдалося виконати завдання ":app:checkStagingDebugAarMetadata".
Не вдалося вирішити всі файли для конфігурації ":app:stagingDebugRuntimeClasspath". Не вдалося знайти com.eightbitlab:blurview:1.6.6. Шукали в таких місцях:`
для мене, як я можу встановити цю реалізацію?
same problem