Skip to content

fix(reader): anchor progress restore to saved page - #369

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-376081-anchor-restore-to-saved-page
Sep 8, 2026
Merged

fix(reader): anchor progress restore to saved page#369
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-376081-anchor-restore-to-saved-page

Conversation

@add-uos

@add-uos add-uos commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Restore of reading progress could regress one page because the saved whole-document ratio was converted with a mid-startup layout while fit-width scale was still changing; the drifted page was then written back and pinned by later deform runs.

Guard the restore with the saved page as anchor: page updates are ignored until layout stays unchanged for 400ms, then the fine-grained ratio is re-applied and falls back to the saved page when it drifts.

阅读进度恢复可能回退一页:fit-width 缩放启动期仍在变化,整篇比例
按中间态布局换算的绝对位置跨页,页码被污染后又被后续 deform 固化
并落盘。

恢复期以保存页码为锚:布局连续 400ms 无变化前忽略页码回写,稳定
后执行精细恢复,跨页时回退锚点页。

Log: 修复重开文档时阅读进度回退到上一页的问题
PMS: BUG-376081
Influence: 文档查看器阅读进度恢复逻辑,恢复不再受启动布局变化影响。

Summary by Sourcery

Anchor reading-progress restoration to the saved page until the document layout stabilizes, then validate the final position to prevent page regressions.

Bug Fixes:

  • Prevent reading-progress restoration from reverting to the wrong page when startup layout changes affect position calculations.

Enhancements:

  • Stabilize layout before applying fine-grained progress restoration, preserve the saved page as an anchor during recovery, and fall back to it if the restored ratio crosses page boundaries.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 11 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Reworks reading-progress restoration to wait for 400 ms of layout stability, keep the saved page as an anchor while fit-width/layout changes are occurring, and validate ratio-based restoration before allowing page state to be updated and persisted.

Sequence diagram for anchored reading-progress restoration

sequenceDiagram
    participant DocSheet
    participant RestoreTimer as RestoreSettleTimer
    participant SheetBrowser
    participant PageState as PageStateAndPersistence

    DocSheet->>DocSheet: beginRestoreGuard()
    DocSheet->>RestoreTimer: start(400ms)
    SheetBrowser-->>DocSheet: sigPageChanged(page)
    DocSheet-->>PageState: Ignore page update while guard active
    SheetBrowser-->>DocSheet: sigDeformed()
    DocSheet->>RestoreTimer: start(400ms)
    RestoreTimer-->>DocSheet: timeout
    DocSheet->>SheetBrowser: restoreScrollPosition(scrollPosition)
    SheetBrowser-->>DocSheet: currentPage()
    alt restored page differs from anchor page
        DocSheet->>SheetBrowser: setCurrentPage(anchorPage)
    end
    DocSheet-->>PageState: Allow final page state and restoration signals
Loading

State diagram for reading-progress restoration guard

stateDiagram-v2
    [*] --> RestoreGuard
    RestoreGuard: Saved page is the anchor
    RestoreGuard: Ignore sigPageChanged updates
    RestoreGuard --> RestoreGuard: sigDeformed / restart 400ms timer
    RestoreGuard --> LayoutSettled: 400ms without sigDeformed
    LayoutSettled: restoreScrollPosition(scrollPosition)
    LayoutSettled --> RestoreComplete: currentPage matches anchor
    LayoutSettled --> RestoreComplete: currentPage differs / setCurrentPage(anchorPage)
    RestoreComplete: Enable page updates and persistence
    RestoreComplete --> [*]
Loading

File-Level Changes

Change Details Files
Adds a layout-stability signal and delayed restore guard to prevent startup reflow from corrupting saved reading progress.
  • Emits a completion signal after browser deformation/layout rebuild.
  • Starts a single-shot 400 ms settle timer and resets it whenever another deformation occurs.
  • Anchors page-change handling to the saved page during the guard, suppressing operation-state updates and progress persistence.
  • After layout settles, reapplies the saved fine-grained scroll ratio and falls back to the anchor page if the restored page differs.
  • Stops and clears the guard during sheet shutdown and preserves the existing restore notifications after final recovery.
reader/browser/SheetBrowser.cpp
reader/browser/SheetBrowser.h
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Restore of reading progress could regress one page because the saved
whole-document ratio was converted with a mid-startup layout while
fit-width scale was still changing; the drifted page was then written
back and pinned by later deform runs.

Guard the restore with the saved page as anchor: page updates are
ignored until layout stays unchanged for 400ms, then the fine-grained
ratio is re-applied and falls back to the saved page when it drifts.

阅读进度恢复可能回退一页:fit-width 缩放启动期仍在变化,整篇比例
按中间态布局换算的绝对位置跨页,页码被污染后又被后续 deform 固化
并落盘。

恢复期以保存页码为锚:布局连续 400ms 无变化前忽略页码回写,稳定
后执行精细恢复,跨页时回退锚点页。

Log: 修复重开文档时阅读进度回退到上一页的问题
PMS: BUG-376081
Influence: 文档查看器阅读进度恢复逻辑,恢复不再受启动布局变化影响。
@add-uos
add-uos force-pushed the fix-376081-anchor-restore-to-saved-page branch from eb51605 to dcb3cad Compare September 8, 2026 01:15
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos

add-uos commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit f15ae39 into linuxdeepin:master Sep 8, 2026
9 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.

3 participants