Boosting Session Replay performance on iOS with View Renderer V2
Blog post from Sentry
After the release of Session Replay for Mobile, feedback indicated performance issues on older iOS devices, prompting a journey to optimize the feature. The challenge centered around frame rendering, where each frame, captured every second, was causing significant main thread hangs due to the high processing time required to render screenshots. To address this, the team shifted from Apple's high-level UIGraphicsImageRenderer API to a custom renderer using CoreGraphics contexts, which significantly reduced rendering times by about 80%. Despite further optimization attempts, like leveraging layer.render(in:), some graphical elements weren't fully captured, though the new renderer still reduced frame drops substantially on older devices. The optimized solution, initially available as an experimental feature in Sentry Apple SDK v8.48.0, became the default in v8.50.2 after positive feedback. While the improvements are notable, challenges remain, particularly with graphics-heavy scenarios and HDR content, which are being addressed in future updates.