Skip to content

fix(android): crash on resetting borderStyle with props 2.0#56228

Closed
hannojg wants to merge 1 commit into
react:mainfrom
hannojg:fix/android-bordertsyle-crash
Closed

fix(android): crash on resetting borderStyle with props 2.0#56228
hannojg wants to merge 1 commit into
react:mainfrom
hannojg:fix/android-bordertsyle-crash

Conversation

@hannojg

@hannojg hannojg commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary:

The problem

When enabling props 2.0 with the feature flags:

  override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = true
  override fun enableExclusivePropsUpdateAndroid(): Boolean = true
  override fun enablePropsUpdateReconciliationAndroid(): Boolean = true

setting the style for borderStyle to undefined causes a crash:

Screen_recording_20260326_092132.mp4
Expand for crash stack
Error while updating prop borderStyle
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
	at com.facebook.react.uimanager.ViewManagersPropertyCache$StringPropSetter.getValueOrDefault(ViewManagersPropertyCache.java:291)
	at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:86)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.kt:155)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater$GenericViewManagerDelegate.setProperty(ViewManagerPropertyUpdater.kt:188)
	at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:102)
	at com.facebook.react.fabric.mounting.SurfaceMountingManager.updateProps(SurfaceMountingManager.kt:635)
	at com.facebook.react.fabric.mounting.SurfaceMountingManager.updateProps(SurfaceMountingManager.kt:598)
	at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.kt:127)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.kt:379)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems$lambda$7$lambda$6(MountItemDispatcher.kt:269)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.$r8$lambda$4xp_oXLXKRRjXh_WfqmwhGWbzaM(Unknown Source:0)
	at com.facebook.react.fabric.mounting.MountItemDispatcher$$ExternalSyntheticLambda4.invoke(D8$$SyntheticClass:0)
	at com.facebook.react.internal.tracing.PerformanceTracer.trace(PerformanceTracer.kt:46)
	at com.facebook.react.internal.tracing.PerformanceTracer.trace(PerformanceTracer.kt:35)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.kt:250)
	at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.kt:94)
	at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1581)
	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:42)
	at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.kt:58)
	at com.facebook.react.modules.core.ReactChoreographer.$r8$lambda$nSkFhrr5T7rop_XKwzlLov4NLLw(Unknown Source:0)
	at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1628)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1639)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1235)
	at android.view.Choreographer.doFrame(Choreographer.java:1160)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1613)
	at android.os.Handler.handleCallback(Handler.java:1070)
	at android.os.Handler.dispatchMessage(Handler.java:125)
	at android.os.Looper.dispatchMessage(Looper.java:333)
	at android.os.Looper.loopOnce(Looper.java:263)
	at android.os.Looper.loop(Looper.java:367)
	at android.app.ActivityThread.main(ActivityThread.java:9287)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)

The bug & its fix

The problem is that we clear the value of borderStyle using NULL:

https://github.com/facebook/react-native/blob/4f908f433044279b7340c1933792b15aa5796a32/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp#L382

where NULL seems to be defined as 0:

Screenshot 2026-03-26 at 09 12 56

so, folly treats this as a 0.0 and we get a double for a value meant to be null / optional.

The fix is to change this to a proper folly nullish-value, as this PR does. This fixes the crash:

Screen_recording_20260326_091533.mp4

(I think there are other places where this is being misused, but i will make individual PRs for those cases!)

Changelog:

[ANDROID] [FIXED] - Fixed crash when enabling props 2.0 and setting borderStyle to undefined

Test Plan:

You can test the crash before with the following code in the playground app:

https://github.com/facebook/react-native/compare/main...hannojg:react-native:hannojg/reproduction-borderstyle-issue?expand=1

You can then test and see how this fix resolves the crash.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 26, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 26, 2026
@meta-codesync

meta-codesync Bot commented Mar 26, 2026

Copy link
Copy Markdown

@zeyap has imported this pull request. If you are a Meta employee, you can view this in D98322741.

@meta-codesync meta-codesync Bot closed this in 9e058db Mar 26, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @hannojg in 9e058db

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants