Skip to content

fix: prepare captures while virtual list updates remain pending - #56

Open
rdlabo wants to merge 2 commits into
mainfrom
fix/capture-after-tab-refresh
Open

rdlabo wants to merge 2 commits into
mainfrom
fix/capture-after-tab-refresh

Conversation

@rdlabo

@rdlabo rdlabo commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

After a tab switch clears cached pixels, virtual list recycling can keep the update queue dirty during momentum scrolling. Native controls have already acknowledged a new revision, but capture preparation waits for an idle queue and can remain on the previous revision.

Pass acknowledged sources to capture preparation immediately after ownership transfer, preserving the navigation/vertical-gesture guards. Keep the existing settled refresh as a fallback. Crossfade completion/cancellation explicitly invalidates prepared pixels so a frame captured during the acquisition fade cannot remain cached for a later overlay. Add a regression that holds the next update pending and verifies the acknowledged revision is already available to capture preparation.

Validation: regression fails before the change; all 421 Core tests and all 43 adapter tests pass after it. A deferred Animation.finished regression also fails before the fade-completion invalidation fix.

Device limitation: repeated tab-switch + momentum-scroll behavior still needs end-to-end device confirmation. The regression verifies capture scheduling rather than UIKit screenshot pixels. This is complementary to the Engine visual-invalidation fix: webview-native-ui/engine#59.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

レビュー

CI はすべて green です。変更は最小限で、原因(virtual list の recycle で updateQueue.dirty が立ち続け、finally 内の settled consider が呼ばれない)に直接手を入れているので、方針はよいと思います。

確認した点は次のとおりです。

  • runtime.ts の新しい projectionSurfaces.consider(acceptedRevision, acknowledged) は ack の直後に呼ばれ、finally の settled 経路でも同じ revision でもう一度呼ばれます。Engine 側の consider は consideredLayout と latest.revision で重複を吸収するので、余分な capture は起きません。
  • createCrossfade(win, () => projectionSurfaces.changed()) は projectionSurfaces の宣言より前に書かれていますが、呼ばれるのは fade 完了時(遅延)なので TDZ にはなりません。teardown 時の cancelAll から changed() が呼ばれても、Engine 側で stopped を見て止まります。
  • fade 完了後の changed() で visualRevision が進んで再 schedule() されるので、fade 中の中間フレームが cache に残らないことはテストで担保されています。

気になる点(軽微):

  1. 新しい consider は invalidated(ack 中に DOM が変わった)場合も呼ばれます。native の pixel は ack 済みの revision なので整合はしているはずですが、直後に schedule() → 次の update で、すぐに invalidate されるはずの capture を取りに行くことになります。momentum 中の capture コストが問題になるようなら、!invalidated の条件を付けるか、今の挙動を意図したものとしてコメントで明示してください。
  2. description にもあるとおり、端末での tab 切り替え + momentum の確認がまだです。engine#59 と組み合わせた状態での実機確認をマージ条件にするのがよいと思います(この PR 単体は engine#59 の新 API には依存していないので、マージ順の制約はありません)。

Written by Devin

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant