Stop gaplessPlayback from keeping every previous image alive by ppamorim · Pull Request #53 · Baseflow/octo_image · GitHub
Skip to content

Stop gaplessPlayback from keeping every previous image alive - #53

Draft
ppamorim wants to merge 1 commit into
Baseflow:mainfrom
ppamorim:fix_gapless_handler_chain
Draft

ppamorim wants to merge 1 commit into
Baseflow:mainfrom
ppamorim:fix_gapless_handler_chain

Conversation

@ppamorim

@ppamorim ppamorim commented Oct 7, 2026

Copy link
Copy Markdown

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix.

⤵️ What is the current behavior?

With gaplessPlayback: true, every image change keeps the current ImageHandler as the previous one. That handler's placeholder is its own previous handler's build, so the handlers form a chain that is never cut. Every earlier handler and its ImageProvider (including a MemoryImage's bytes) stays reachable for as long as the OctoImage is mounted. If images are swapped faster than they load, the placeholders also nest: after 5 swaps the tree holds 5 nested Image widgets.

🆕 What is the new behavior (if this is a feature change)?

The kept previous handler is a fresh one built from the old widget, so it references no earlier handler. At most one previous image is held. It is replaced only once the current image has shown a frame, so swapping faster than images load keeps showing the last image that actually appeared. Version is bumped to 2.1.4.

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

flutter test test/gapless_playback_test.dart. It shows a loaded image, then swaps to 5 images that never load, and expects only the newest image and the original one in the tree. It fails on main.

📝 Links to relevant issues/docs

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines
  • Relevant documentation was updated
  • Rebased onto current main
  • Version bumped in pubspec.yaml and dated CHANGELOG.md entry added (skip for docs-only and CI-only changes)

🤖 Generated with Claude Code

… 2.1.4

With gaplessPlayback on, each image change kept the current ImageHandler
as the previous one, and that handler's placeholder was its own previous
handler's build. The chain was never cut, so every earlier handler and
its ImageProvider stayed reachable while the widget was mounted.

Keep a fresh handler built from the old widget instead, so it holds no
earlier handler, and only replace it once the current image has shown a
frame. Swapping faster than images load now keeps the last image that
was actually shown.

Co-Authored-By: Claude <noreply@anthropic.com>
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