Skip to content

Revert "perf: Convert events to jsi::Value without a JSON round-trip in handleEvent"#9687

Merged
tomekzaw merged 1 commit into
mainfrom
revert-9581-@tomekzaw/handle-event-skip-json-roundtrip
Jun 17, 2026
Merged

Revert "perf: Convert events to jsi::Value without a JSON round-trip in handleEvent"#9687
tomekzaw merged 1 commit into
mainfrom
revert-9581-@tomekzaw/handle-event-skip-json-roundtrip

Conversation

@tomekzaw

@tomekzaw tomekzaw commented Jun 17, 2026

Copy link
Copy Markdown
Member

Reverts #9581

#9581 made handleEvent consume the incoming event payload map via NativeMap::consume(), which moves out its folly::dynamic and marks the map consumed. That map is owned by the React Native event and is also dispatched to JS, and some events return a cached instance from getEventData(), so consuming it in Reanimated corrupts the downstream dispatch and throws ObjectAlreadyConsumedException: Map already consumed on Android. Reverting to be safe for the 4.5.0 release; a fixed version that keeps the optimization is in #9686.

Confirmed crashes:

MapLibre MapChangeEvent:

com.facebook.react.bridge.ObjectAlreadyConsumedException: Map already consumed
	at com.facebook.react.fabric.events.EventEmitterWrapper.dispatchUniqueEvent(Native Method)
	at com.facebook.react.fabric.events.EventEmitterWrapper.dispatchUnique(EventEmitterWrapper.kt:71)
	at com.facebook.react.fabric.FabricUIManager.receiveEvent(FabricUIManager.java:1149)
	at com.facebook.react.fabric.events.FabricEventEmitter.receiveEvent(FabricEventEmitter.kt:28)
	at com.facebook.react.uimanager.events.Event.dispatchModern(Event.kt:192)
	at com.facebook.react.uimanager.events.FabricEventDispatcher.dispatchEvent(FabricEventDispatcher.kt:51)
	at org.maplibre.reactnative.components.mapview.MLRNMapView.handleMapChangedEvent(MLRNMapView.kt:1513)
	at org.maplibre.reactnative.components.mapview.MLRNMapView.onWillStartRenderingMap(MLRNMapView.kt:731)

Expo view events (KEventEmitterWrapper.UIEvent, for example expo-image):

com.facebook.react.bridge.ObjectAlreadyConsumedException: Map already consumed
	at com.facebook.react.fabric.events.EventEmitterWrapper.dispatchEvent(Native Method)
	at com.facebook.react.fabric.events.EventEmitterWrapper.dispatch(EventEmitterWrapper.kt:47)
	at com.facebook.react.fabric.FabricUIManager.receiveEvent(FabricUIManager.java:1151)
	at com.facebook.react.fabric.events.FabricEventEmitter.receiveEvent(FabricEventEmitter.kt:28)
	at com.facebook.react.uimanager.events.Event.dispatchModern(Event.kt:192)
	at com.facebook.react.uimanager.events.FabricEventDispatcher.dispatchEvent(FabricEventDispatcher.kt:51)
	at expo.modules.kotlin.events.KEventEmitterWrapper.emit(KModuleEventEmitterWrapper.kt:109)
	at expo.modules.kotlin.viewevent.ViewEvent.invoke(ViewEvent.kt:47)
	at expo.modules.image.events.GlideRequestListener$onResourceReady$1.invokeSuspend(GlideRequestListener.kt:61)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts the previously introduced optimization that converted Android event payloads to jsi::Value without a JSON round-trip in NativeProxy::handleEvent, restoring the older JSON-stringify + JSON-parse approach for event payload conversion.

Changes:

  • Reintroduces JSON serialization/deserialization in handleEvent (WritableMap::toString()jsi::Value::createFromJsonUtf8).
  • Removes now-unneeded includes related to the reverted direct conversion path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tomekzaw tomekzaw added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit 0d52e18 Jun 17, 2026
9 checks passed
@tomekzaw tomekzaw deleted the revert-9581-@tomekzaw/handle-event-skip-json-roundtrip branch June 17, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants