Skip to content

fix(compose): synchronize offset after viewport changes - #113

Merged
bytemain merged 1 commit into
staging2from
mingqi/task183-viewport-offset-sync
Aug 4, 2026
Merged

fix(compose): synchronize offset after viewport changes#113
bytemain merged 1 commit into
staging2from
mingqi/task183-viewport-offset-sync

Conversation

@bytemain

@bytemain bytemain commented Aug 3, 2026

Copy link
Copy Markdown
Member

Root cause

KNode.updateScrollViewOffset() derives a corrected Compose scroll offset from the native offset, but guards the write by comparing the corrected value back to that same native offset. In the default and in-bounds branches those values are identical, so a stale KuiklyScrollInfo.composeOffset is not synchronized after a viewport resize.

On Android this can leave native child frames based on the old Compose offset while KRRecyclerContentView already uses the new native offset. The attached row window then sits entirely outside the viewport even though Lazy placement completed.

Change

  • isolate viewport-change offset correction as a behavior-testable helper
  • return a correction only when the corrected native value differs from the prior Compose offset
  • preserve the existing shrink/expand boundary semantics
  • cover stale-bottom adoption, pre-native-echo shrink, mid-list no-op, and expansion clamp

Impact and review scope

This is a commonMain Scroller/LazyList offset contract change, not a Thread-only or Android-only change. Review and Hosted validation must cover Android/iOS/OHOS plus shared offset consumers, including shrink/expand, fling/settle, scroll-to-index, Pager, pull-to-refresh, and content-size changes. The PR intentionally remains Draft until those independent gates close.

Evidence

  • focused test: :compose:testDebugUnitTest --tests com.tencent.kuikly.compose.ui.node.ViewportOffsetCorrectionTest — 4/4 PASS
  • Android API 36 counterfactual on the same Thread that produced the frozen white sample: 16/16 automated IME show/hide cycles remained non-white
  • every admitted cycle had KRRecyclerView 0..899 and direct attached-row coverage ending exactly at viewport bottom 899
  • no Alpha-process crash/ANR in the admitted cycles

The local runtime carrier also contained already-landed diagnostic reliability changes used only to prove the physical boundary; those files are not part of this PR.

Signed-off-by: MingQi mingqi@mail.build

@bytemain
bytemain force-pushed the mingqi/task183-viewport-offset-sync branch from 723d78c to 3ea7c96 Compare August 3, 2026 20:43
Signed-off-by: MingQi <mingqi@mail.build>
@bytemain
bytemain force-pushed the mingqi/task183-viewport-offset-sync branch from 3ea7c96 to 175c8ac Compare August 3, 2026 20:59
@bytemain
bytemain marked this pull request as ready for review August 4, 2026 05:49
@bytemain
bytemain merged commit 8190595 into staging2 Aug 4, 2026
6 checks passed
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