question-mark
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

http://pastebin.com/270Wg6Pu

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

2reactions
newyankeecodeshopcommented, Feb 22, 2021

I believe the crash is caused by the custom Yoga measure implementation here: https://github.com/callstack/react-native-slider/blob/45c2a5438f0d7e2dd586a663c4043e795d6c1761/src/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java#L69

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?

1reaction
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(AnimatorSet.java:700)
	at android.animation.AnimatorSet.clone(AnimatorSet.java:51)
	at android.animation.Animator$AnimatorConstantState.newInstance(Animator.java:562)
	at android.animation.Animator$AnimatorConstantState.newInstance(Animator.java:543)
	at android.content.res.ConstantState.newInstance(ConstantState.java:51)
	at android.content.res.ConstantState.newInstance(ConstantState.java:59)
	at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:133)
	at android.graphics.drawable.AnimatedVectorDrawable$AnimatedVectorDrawableState$PendingAnimator.newInstance(AnimatedVectorDrawable.java:567)
	at android.graphics.drawable.AnimatedVectorDrawable$AnimatedVectorDrawableState.inflatePendingAnimators(AnimatedVectorDrawable.java:545)
	at android.graphics.drawable.AnimatedVectorDrawable.applyTheme(AnimatedVectorDrawable.java:377)
	at android.graphics.drawable.DrawableContainer$DrawableContainerState.applyTheme(DrawableContainer.java:865)
	at android.graphics.drawable.DrawableContainer.applyTheme(DrawableContainer.java:577)
	at android.graphics.drawable.StateListDrawable.applyTheme(StateListDrawable.java:370)
	at android.graphics.drawable.AnimatedStateListDrawable.applyTheme(AnimatedStateListDrawable.java:391)
	at android.content.res.Resources.loadDrawable(Resources.java:2615)
	at android.content.res.VivoResources.loadDrawable(VivoResources.java:220)
	at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
	at android.widget.AbsSeekBar.<init>(AbsSeekBar.java:95)
	at android.widget.SeekBar.<init>(SeekBar.java:85)
	at android.widget.SeekBar.<init>(SeekBar.java:81)
	at androidx.appcompat.widget.AppCompatSeekBar.<init>(AppCompatSeekBar.java:47)
	at com.reactnativecommunity.slider.ReactSlider.<init>(ReactSlider.java:68)
	at com.reactnativecommunity.slider.ReactSliderManager.createViewInstance(ReactSliderManager.java:129)
	at com.reactnativecommunity.slider.ReactSliderManager.createViewInstance(ReactSliderManager.java:40)
	at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:139)
	at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:82)
	at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:269)
	at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:179)
	at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:972)
	at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:943)
	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:28)
	at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:174)
	at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:84)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:890)
	at android.view.Choreographer.doCallbacks(Choreographer.java:704)
	at android.view.Choreographer.doFrame(Choreographer.java:637)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:878)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5619)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737)
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found