Skip to content

Context.get_current_texture() can now raise DrawCancelled#820

Merged
almarklein merged 8 commits into
mainfrom
draw-cancelled
Jul 8, 2026
Merged

Context.get_current_texture() can now raise DrawCancelled#820
almarklein merged 8 commits into
mainfrom
draw-cancelled

Conversation

@almarklein

Copy link
Copy Markdown
Member

Closes #819.

Since the latest update, when a window is hidden, we cannot obtain the surface texture. We had two options:

  • provide a dummy texture to render to.
  • raise an exception so downstream code can react appropriately.

Since this is a reliable method to detect that a window is not actually visible, and not all GUI toolkits have a way to determine the visibility of a window, we decided for the latter.

This does mean downstream code needs to adjust. Any code based on rendercanvas can simply update rendercanvas, see pygfx/rendercanvas#221.

@almarklein
almarklein requested a review from Vipitis July 2, 2026 12:09
@almarklein almarklein changed the title Context.get_current_texture() can now raise DrawCancelled Context.get_current_texture() can now raises DrawCancelled Jul 2, 2026
@almarklein almarklein changed the title Context.get_current_texture() can now raises DrawCancelled Context.get_current_texture() can now raise DrawCancelled Jul 2, 2026

@Vipitis Vipitis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I skimmed the diff and looks good to me. Is the whole dummy thing not needed anymore? Feels great.

@Vipitis

Vipitis commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Also is there some reasonable way to automatically test for this? Or would you need gui automation etc?
Not specifically to expect the error as it might not work with all backend and all guis, but just to spot any panics easier.

@almarklein

Copy link
Copy Markdown
Member Author

Is the whole dummy thing not needed anymore?

No, because we can use the same frame-skip mechanism for these cases. The dummy texture was there to allow get_current_texture() to always Just Work, even if the result would not be visible.

Also is there some reasonable way to automatically test for this?

The manual test is to run an example with glfw, hide the window, check that there are no errors, and observe that reported fps is low at first when you bring it back to front. Automating that in CI is very tricky at the least.

@almarklein
almarklein merged commit 8a454a1 into main Jul 8, 2026
19 checks passed
@almarklein
almarklein deleted the draw-cancelled branch July 8, 2026 12:17
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.

Hiding a GLFW window causes surface error

2 participants