You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Session replay screenshot mode: with nothing masked, frames are encoded at native scale and the encode queue falls minutes behind capture #958
With nothing to mask, replay frames reach PostHog minutes after they are captured, and the delay grows during the session.
On an iPhone (TestFlight build, iOS 27.0.1, Wi-Fi), frames reached PostHog 7 to 35 minutes after capture during a 15-minute session. Frames averaged about 119 KB each.
On the iOS 27 simulator (Debug build), frames lagged by several minutes, and the app kept sending replay data and using about 90% of a CPU core five minutes after the screen stopped changing.
$sdk_debug_replay_internal_buffer_length stayed between 0 and 9 on every event, so the persisted replay queue was not behind. The backlog is before it.
A 5-second stack sample of the simulator app, taken five minutes after the screen stopped changing, found the com.posthog.PostHogReplayIntegration thread in PHWebPEncode for 1,911 of 1,911 samples, under RRWireframe.toDict() → UIImage.toBase64(_:).
Why (source, 3.92.0)
The screenshot is rendered at the screen's native scale: PostHog/Replay/UIView+Util.swift:131-132.
Each frame is encoded on one serial queue at utility QoS: PostHog/Replay/PostHogReplayIntegration.swift:166-167, :805.
A frame with masked regions is redrawn at scale 1 before encoding (PostHog/Replay/RRWireframe.swift:66, :117). A frame with nothing masked is encoded at native scale (PostHog/Replay/RRWireframe.swift:124), which is 9 times the pixels at 3x.
Encoding is WebP at quality 0.3 (PostHog/Replay/UIImage+Util.swift:13-15).
So turning masking off moves every frame from the scale-1 path to the native-scale path, and WebP encoding at native scale is slower than the default one-second throttleDelay. Frames wait on the serial queue with their capture timestamps and arrive late.
Request
One of:
Encode unmasked screenshots at scale 1, as masked ones already are.
Add a screenshot scale (and perhaps quality) option to PostHogSessionReplayConfig.
Separately, it may help to drop older pending frames when the encode queue falls behind, so a replay stays close to real time instead of trailing by minutes.
Workaround
We add a clear 1 × 1 point view with .postHogMask() at the window's top-left corner, so every frame takes the scale-1 path. Replays then show a 1-point black mark in that corner. We would like to remove it.
We're seeing the same thing in a React Native app (posthog-react-native 4.81.2 / @posthog/react-native-plugin 2.12.6, which pins posthog-ios 3.88.2; screenshot mode, maskAllTextInputs: false, maskAllImages: false, throttleDelayMs: 1000).
Measured on a physical iPhone 14 Pro (iOS 27.0.1) with an optimized Release build:
With nothing masked, every frame is rendered and WebP-encoded at native scale (1179×2556). Each encode takes about 265 ms of CPU, and it runs about once a second, so about 25% of a core on every screen.
The cost is the same on a visually static screen: capture is triggered by layoutSublayers anywhere in the app, and duplicate frames are only detected by hashing the base64 output, so unchanged frames are fully encoded before being dropped.
Frames with any masked view go through maskImage at scale 1, which is about 9× fewer pixels.
For now we've shipped the workaround from this issue (a 1×1-point PostHogMaskView in the top-left corner) plus a 2 s throttle. It works, but it relies on a side effect and leaves a 1-point mark in every replay.
Fixed in posthog-ios 3.92.7 by #967. Screenshots without masks now upload at the same size as masked ones, so the 1×1 mask workaround is no longer needed.
@billsbooth for React Native: the plugin pins posthog-ios below 3.89, so it needs PostHog/posthog-js#5482 and a plugin release before RN apps get this fix.
Activity
turnipdabeets commentedon Oct 21, 2026
This might related to #911 @ioannisj
@ioannisj thoughts on making
screenshotScaleconfigurable so it could be captured at 1x or a higher fedelity?billsbooth commentedon Oct 22, 2026
We're seeing the same thing in a React Native app (posthog-react-native 4.81.2 / @posthog/react-native-plugin 2.12.6, which pins posthog-ios 3.88.2; screenshot mode,
maskAllTextInputs: false,maskAllImages: false,throttleDelayMs: 1000).Measured on a physical iPhone 14 Pro (iOS 27.0.1) with an optimized Release build:
layoutSublayersanywhere in the app, and duplicate frames are only detected by hashing the base64 output, so unchanged frames are fully encoded before being dropped.maskImageat scale 1, which is about 9× fewer pixels.For now we've shipped the workaround from this issue (a 1×1-point
PostHogMaskViewin the top-left corner) plus a 2 s throttle. It works, but it relies on a side effect and leaves a 1-point mark in every replay.Could you consider:
screenshotScaleoption in the session replay config (PR feat: add experimental GPU screenshot capture for session replay #911 adds one, but only for the experimental capture path).Happy to share more profiling detail if useful.
turnipdabeets commentedon Oct 29, 2026
Fixed in posthog-ios 3.92.7 by #967. Screenshots without masks now upload at the same size as masked ones, so the 1×1 mask workaround is no longer needed.
@billsbooth for React Native: the plugin pins posthog-ios below 3.89, so it needs PostHog/posthog-js#5482 and a plugin release before RN apps get this fix.