Skip to content

RenderRepaintBoundary's toImage() & visitChildElements() out of sync #161228

Description

@vaind

Steps to reproduce

Hey, I'm working on screen recording (replay capture) and am facing an issue where the tree walked with visitChildElements() is out of sync to what is currently rendered by RenderRepaintBoundary.toImage(). The code runs in a postFrame callback and there's no async gap between capturing the image and walking the tree (https://github.com/getsentry/sentry-dart/blob/8de999e3d94a02467670c77f859ab31d4ad71e40/flutter/lib/src/screenshot/recorder.dart#L81-L88), yet I can consistently capture frames that seem to indicate the tree walking shows a "future" version of what the image would look like. This is a problem because I need to render a mask over some elements (mostly it's about obscuring text). I assume the discrepancy is because the tree may have already been updated before the PostFrameCallback. Is there any way to recognize the widget tree is out of date with what the RenderObject would render toImage()? This way I could skip processing and try at a later time in the future.

Expected results

visitChildElements() walks the same widget tree as RenderRepaintBoundary toImage() captures

Actual results

When changes occur, RenderRepaintBindary() renders the old tree for at least one frame (one addPostFrameCallback() execution)

Code sample

Code sample

I'm willing to create a repro & attach a video if someone can confirm that this behavior looks like a bug, not that I misunderstood something conceptually.

[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.26100.2605], locale en-US)
    • Flutter version 3.27.0 on channel stable at C:\Users\dlugo\scoop\apps\flutter\3.27.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (4 weeks ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\dlugo\scoop\apps\android-sdk\current
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\Users\dlugo\scoop\apps\android-sdk\current
    • Java binary at: C:\Users\dlugo\scoop\apps\openjdk17\current\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.2+8-86)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.12.35527.113
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[√] VS Code (version 1.96.2)
    • VS Code at C:\Users\dlugo\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.102.0

[√] Connected device (4 available)
    • LYA L29 (mobile)  • LHS7N19110005914 • android-arm64  • Android 10 (API 29)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [Version 10.0.26100.2605]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 131.0.6778.205
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 131.0.2903.112

[√] Network resources
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions