Skip to content

Refactor canvas and loop closing logic#227

Draft
almarklein wants to merge 18 commits into
mainfrom
wx-close
Draft

Refactor canvas and loop closing logic#227
almarklein wants to merge 18 commits into
mainfrom
wx-close

Conversation

@almarklein

@almarklein almarklein commented Jul 6, 2026

Copy link
Copy Markdown
Member

This started with an attempt to clean up the wx closing mechanics, but ended up being a complete overhaul of the closing mechanics of the base class and all backends.

We have many more backend-specific tests that run on CI now, helping make rendercanvas more stable across the diffetent backends.

Changes

  • All closing flows must go through BaseRenderCanvas.close().
  • When the last canvas is closed, the loop is stopped. The base class handles this.
  • When the loop is stopped, all canvases are closed.
  • We detect loops starting with a little coroutine, but no longer poll canvases being closed with a loop-task.
  • We detect loops closing either by 1) the last canvas being closed, or 2) for async loops by the coro to be cancelled.
  • Added comprehensive tests for all backends, especially to test stopping and cleanup for GUI backends. All run on CI.
  • The wx loop is now a fully functional loop (it was a bit of a special case before this pr).
  • Wx canvas are now cleaned up by gc.
  • For all backends, loop.run() without any canvases, does one flush of the event queue and then closes.

Notes for backend authors

TODO

@almarklein almarklein changed the title More fix wx closing Refactor canvas and loop closing logic Jul 17, 2026
@almarklein almarklein mentioned this pull request Jul 17, 2026
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