professional-work

02

Location-based social platform — execution boundaries for gestures and server state

I linked the GPS button to the bottom sheet's position and worked on synchronizing SharedValue and React state in card swipes and likes. Immediate visual responses stayed on the UI thread, while confirmed actions were passed to the JS thread.

preview
UI 스레드의 바텀시트 반응과 JS 스레드로 전달되는 확정된 행동을 구분한 설명용 도식 / Illustrative diagram of gesture response and confirmed actions across UI and JS threads

A GPS button that follows the bottom sheet

When a user dragged the place-detail bottom sheet in the location-based social platform, the GPS button above the map needed to follow its position. I worked with @gorhom/bottom-sheet’s animatedPosition as a SharedValue and calculated the button’s position in useAnimatedStyle, avoiding React state updates for each movement.

The key question was which thread the calculation had to wait for. Style calculations could continue on the UI thread while the JS thread handled React logic. Reanimated runs this logic through worklets, which are JavaScript functions rather than GPU shaders. Reanimated’s Worklets documentation

Visual response and confirmed state

Card swipes and likes exposed another issue. While using useAnimatedReaction, Gesture.Tap and runOnJS, SharedValue on the UI thread and React state on the JS thread could represent different moments.

Changing a SharedValue does not trigger a React render, and writes from the JS thread take effect asynchronously. Treating these values as one state updated simultaneously could leave gesture responses and React decisions out of step. Reanimated’s useSharedValue documentation

I separated their responsibilities: gestures and immediate visual responses used SharedValue on the UI thread, while confirmed actions crossed to the JS thread for React state and API requests. Because runOnJS schedules functions asynchronously, dispatching an action and completing its state update remained distinct events. Reanimated’s runOnJS documentation

The practical rule was to distinguish position changes on each frame from user actions that needed to reach the server. Before copying animation values into React state, I needed to decide which changes other logic actually needed to know about.

Why execution boundaries mattered

Studying Chromium’s main and compositor threads now gives me another way to understand this work. Their responsibilities differ from React Native’s threads, but both raise the question of how interactions can avoid waiting on general application logic.

GPU rendering and animation logic waiting on the JS thread are separate concerns. Moving calculations to the UI thread loses some of its benefit if each frame still depends on JS-thread work.

The same app’s map and WebView integration coordinated selection across two surfaces. This work connected immediate visual responses with confirmed state across separate execution flows.