Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReactSlider crash on Android release version

See original GitHub issue

This issue was originally created by @ssg-luke as facebook/react-native#9979.

Issue Description

Hard crash randomly and unexpectedly on Android release version only (debug is fine, iOS is fine on both debug and release) when hiding and displaying sliders based on a state variable.

Steps to Reproduce / Code Snippets

We have a number of photo filters in our app which are selected by <TouchableOpacity> components and some have a slider to adjust the blur or brightness etc. These sliders are completely separate from each other and are displayed based on a string stored in the components state called filter.

Here is one such slider from render():

{filter === 'gamify' && ( <View style={styles.filterSlider}> <Text>How retro do you want to go?</Text> <Slider value={this.state.pixelSize} minimumValue={1} maximumValue={5} onValueChange={value => this.setState({pixelSize: value})} /> </View>)}

Expected Results

No crash when hiding and displaying sliders

Stack Trace

java.lang.NullPointerException: Attempt to write to field ‘java.util.ArrayList android.animation.AnimatorSet$Node.nodeDependents’ on a null object reference

Additional Information

  • React Native version: 0.33
  • Platform(s) (iOS, Android, or both?): Android (Release only)
  • Operating System (macOS, Linux, or Windows?): Mac OSX

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

newyankeecodeshopcommented, Feb 22, 2021

I believe the crash is caused by the custom Yoga measure implementation here:

That code runs on the Yoga layout thread, but it allocates a ReactSlider view. Since ReactSlider extends Android SeekBar, the constructor runs animation and drawable code on different thread than the main thread. I suspect this low-level Android view code is not thread-safe, and not designed to be run on a thread that is not the main thread.

To prevent this code from executing, I changed the style for our <ReactSlider> to include a specific width and height. This prevents Yoga from needing to measure the view. The crash no longer happens for our app.

const style = { height: 40, width: "100%" }

<ReactSlider style={style} ... />

Hope this helps!

P.S. - I don’t know enough about Android view drawing and measurement to know how to implement the measure method without allocating a slider view. Maybe the measure could allocate the view on the main thread and block until that finishes?

BAE86AEC1946B6AB60CCD7452DC811F0commented, Jun 29, 2020

I also have a similar bug with react-native 0.61.5. any update on this?

java.lang.NullPointerException: Attempt to write to field 'java.util.ArrayList android.animation.AnimatorSet$Node.nodeDependents' on a null object reference
	at android.animation.AnimatorSet.clone(
	at android.animation.AnimatorSet.clone(
	at android.animation.Animator$AnimatorConstantState.newInstance(
	at android.animation.Animator$AnimatorConstantState.newInstance(
	at android.content.res.ConstantState.newInstance(
	at android.content.res.ConstantState.newInstance(
	at android.animation.AnimatorInflater.loadAnimator(
	at android.content.res.Resources.loadDrawable(
	at android.content.res.VivoResources.loadDrawable(
	at android.content.res.TypedArray.getDrawable(
	at android.widget.AbsSeekBar.<init>(
	at android.widget.SeekBar.<init>(
	at android.widget.SeekBar.<init>(
	at androidx.appcompat.widget.AppCompatSeekBar.<init>(
	at com.reactnativecommunity.slider.ReactSlider.<init>(
	at com.reactnativecommunity.slider.ReactSliderManager.createViewInstance(
	at com.reactnativecommunity.slider.ReactSliderManager.createViewInstance(
	at com.facebook.react.uimanager.ViewManager.createViewInstance(
	at com.facebook.react.uimanager.ViewManager.createView(
	at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(
	at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(
	at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(
	at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(
	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(
	at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(
	at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(
	at android.view.Choreographer$
	at android.view.Choreographer.doCallbacks(
	at android.view.Choreographer.doFrame(
	at android.view.Choreographer$
	at android.os.Handler.handleCallback(
	at android.os.Handler.dispatchMessage(
	at android.os.Looper.loop(
	at java.lang.reflect.Method.invoke(Native Method)
Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactSlider crash on Android release version · Issue #9 - GitHub
Hard crash randomly and unexpectedly on Android release version only (debug is fine, iOS is fine on both debug and release) when hiding...
Read more >
My release apk is crashing after splashcreen, how do I solve it?
my app crashes after the splash screen, for debug works perfectly. ... "android": "react-native run-android", "ios": "react-native run-ios", ...
Read more >
Slow rendering - Android Developers
Run a release (or at least non-debuggable) version of your app. · Enable Profile GPU Rendering. · There are certain components, such as ......
Read more >
How to Fix Crashing Apps on an iPhone or Android?
10 Solutions to fix App Crashes and Keep Apps Running: For Apple iPhone, Samsung Galaxy, LG, Lenovo and Sony Xperia smartphones. If you've...
Read more >
Fixing React-Native android release build - wesionaryTEAM
Fixing React-Native android release build Android release build crashes on launch but works fine on a development mode. couldn't find DSO to load: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found