Repository navigation
Description
Version
3.88.2 (through @posthog/react-native-plugin 2.12.6 and posthog-react-native 4.81.2)
Steps to Reproduce
- A React Native 0.86 app on the New Architecture (Fabric), Expo SDK 57, with session replay on and sampled at 100%. Replay config from JS:
maskAllTextInputs: true,maskAllImages: false, defaultthrottleDelayMs(1000). The RN plugin forcesscreenshotMode = true. - Open a long scrolling screen built from ordinary RN views (cards with shadows, gradients, text).
- Fling the scroll view fast, several times in a row.
Expected Result
Scrolling stays as smooth as it is with replay off, which is how it behaved on posthog-ios 3.58.1 (through posthog-react-native-session-replay 1.6.0).
Actual Result
After moving from posthog-ios 3.58.1 to 3.88.2, which was the only native dependency change in that app release, fast flings stutter and the deceleration sometimes stops dead, as if the screen had been tapped. It happens about once per throttle interval while a fling is moving. Slow scrolling is fine.
The code path we traced in 3.88.2:
scheduleSettledCapturesamples mask geometry twice, 25 ms apart. During a fling,settleVerdictreturns.motion, either because the displacement is overdriftBudgetPoints(50 pt) or because the two samples can't be paired when rows mount or unmount mid-scroll..motionpassespreferFidelityRenderer: false, soperformScreenshotCapture→collectScreenshotMetadata→UIView.toImageruns(layer.presentation() ?? layer).render(in:)over the whole window at native screen scale, on the main thread. That is a CPU render of the entire layer tree, shadows included, in the middle of the scroll's deceleration.- Since 3.69.9,
maskAllTextInputs: truemakes everyRCTParagraphComponentViewa mask region. On an RN screen almost every fast scroll therefore lands in.motion, andcollectMaskedRegionswalks the view hierarchy twice per capture.
#786 (3.70.1) added the motion band and notes that it has a real cost. The band fires on exactly the gesture where a main-thread stall is most visible.
What we measured: in Sentry, our iOS slow-frame rate on navigation transactions went from about 4.8% on the previous release (posthog-ios 3.58.1) to about 6.9% on this one. The sample is small and navigation spans don't cover scrolling, so treat it as a weak signal. We haven't profiled the stall in Instruments.
From React Native on iOS, the only levers are throttleDelayMs, sampleRate or turning replay off. screenshotModeBackgroundCapture is experimental and slated for removal in 4.0 (#937).
Suggested fix: when the settle check returns .motion, skip or defer the capture until the geometry settles instead of rendering with render(in:) on the main thread. That would match the Android side, where mid-scroll capture jank was raised in PostHog/posthog-android#750 and PostHog/posthog-js#4734. A frame taken once the scroll settles is still accurate, and a frame skipped mid-fling costs the replay very little. Failing that, letting the RN plugin turn the motion fallback off would also work.
Activity
turnipdabeets commentedon Oct 20, 2026
Thanks for the detailed trace @benthomasmtl. Heads up that this is being workied on in #911 and we'll need to wire it through the React Native plugin too, @ioannisj.
turnipdabeets commentedon Nov 15, 2026
@ioannisj, same question as #1035: GPU capture skips the
render(in:)path while the screen is moving. Do you expect it to fix the fling stalls? React Native opt-in comes with posthog-ios 4.0 and plugin 3.0 (PostHog/posthog-js#5734).posthog commentedon Nov 15, 2026
PostHog self-driving picked up this issue. Status: Research is done.
Somebody may already be working on it, so ask before you start a fix.
Report (team access only): https://us.posthog.com/project/2/inbox/reports/01a1ae52-9d6f-73a7-9a6a-0b30704e23b1?link_source=github_comment