Skip to content

fix(reader): webtoon page counter and progress cannot reach 100% at chapter end - #166

Closed
sang765 wants to merge 1 commit into
UsagiApp:develfrom
sang765:fix/webtoon-last-page-progress
Closed

sang765 wants to merge 1 commit into
UsagiApp:develfrom
sang765:fix/webtoon-last-page-progress

Conversation

@sang765

@sang765 sang765 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes webtoon mode where the page counter and reading progress get stuck at 18/19 · 97% even after scrolling to the last page of the newest chapter.

Root causes

  1. Current page never becomes the last page — ReaderViewModel.onCurrentPageChanged resolves the current page as the center of the visible range (first + last) / 2. When the last page is short (credits pages are common), the previous page's window is still partially visible at the bottom, so the center is always the second-to-last page. Additionally, the scroll dispatcher only emits events when item positions change — at max scroll positions freeze, so no further events can ever mark the last page. (Chapters whose last page fills the viewport worked, which is why the bug looked inconsistent.)
  2. Stale state on exit — getCurrentState() probed the page under the last tap/long-press coordinates (sticky downY), so exiting the reader saved an older page: progress regressed in details screen and reopening started at 18/19 again.
  3. Float overshoot — computePercent could produce values slightly above 1f when the chapter count doesn't divide evenly, failing isCompleted/isValid checks and breaking the 100% display.

Changes

  • WebtoonReaderFragment: resolve the current page from viewport geometry — last page at the bottom edge, first page at the top edge, center of visible range otherwise; probe state from the layout manager instead of stale touch coordinates; re-report the page on SCROLL_STATE_IDLE (catches flings landing exactly at max scroll).
  • WebtoonRecyclerView: scroll dispatcher also fires when at-top/at-bottom state flips (fires immediately when the edge is reached mid-drag).
  • ReaderViewModel: clamp computePercent to 1f.
  • TapGridDispatcher / ReaderActivity: visibility reverted to private for fields that no longer have external readers.

Testing

  • Scroll to the end of the latest chapter → counter shows 19/19, percent 100%
  • Exit reader → details screen shows 100%, reopening resumes at the last page
  • Tap/long-press an image (action menu), scroll to the end, exit → state still saved at the last page
  • Scrolling between chapters behaves as before; pull-to-next-chapter still triggers

@sang765 sang765 self-assigned this Nov 3, 2026
@sang765 sang765 added the bug Something isn't working label Nov 3, 2026
- resolve current page from viewport edges so the last page of a
  chapter is always registered (counter and percent stuck at 18/19 / 97%)
- re-report current page when scrolling settles, item positions freeze
  at the scroll edges so no scroll event fires there
- save reading state from viewport geometry instead of stale touch
  coordinates captured on tap/long press
- clamp computed percent to 1f to avoid float overshoot breaking
  isCompleted checks
@sang765
sang765 force-pushed the fix/webtoon-last-page-progress branch from ff99eec to f14eb3e Compare November 3, 2026 09:30
@dragonx943

Copy link
Copy Markdown
Member

Migrated to #168

@dragonx943 dragonx943 closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants