Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mnt direct call draw idle [WIP]#4849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

tacaswell
Copy link
Member

Built on top of#4738

@mdehoon

When I went to implement this I grew confused as to where the canvas knowing it was stale would fit in. Isn't the call todraw_idle the message to the canvas that it is stale?

There were also some issues with the firstdraw_idle going out before all of the objects had finished building them selves addingstale to the canvas in the naive way because callbacks in python get executed synchronously.

I did re-work how the stale state gets propagated and (I think) greatly simplified it by adding a dedicated callback.

As-is this has an issue with__init__ order of operations with the nbagg backend which I don't have time to debug tonight.

I am worried about how this method will interact with nbagg which has a js side event loop running in the browser and then call backs listening to comms on the python side. By hooking into the IPython callbacks we get to leverage their understanding of how to manage things.

@mdboom
Copy link
Member

At first blush, this looks like a nice simplification. Ping me to come back and look again as it progresses.

One possible further simplification:

Maybe include a defaultstale_callback method that is a no-op, rather than requiringif self.stale_callback is not None everywhere it is called? That seems like the kind of thing that could be forgotten down the road.

@mdehoon
Copy link
Contributor

@tacaswell

Isn't the call to draw_idle the message to the canvas that it is stale?

Yes it is. "draw_idle" is a bit of a misnomer; "invalidate" may be better. The purpose of draw_idle is to let the canvas know that it is stale. How the canvas responds to that is up to the backend. Typically, a GUI backend will indeed schedule a redraw when the event loop is idle, but I could imagine that in specific backends draw_idle does something else (e.g. set a flag or something). Not sure if this is what you were asking, but anyway I hope it helps.

@tacaswell
Copy link
MemberAuthor

@mdehoon I disagree about the purpose ofdraw_idle, it is to instruct the canvas that it should redraw at the next opportunity (vsdraw which is telling the canvas to re-renderright now). The details of how this is implemented is up to the backends (and in the case of macosx you deal with this by having an 'invalid' flag which the draw loop knows to mean it should re-draw on this cycle through), but other wise the canvas objects are (publicly) stateless and the implementation in backend bases to passdraw_idle through todraw (which really only matters for agg in terms of the backends we ship) is perfectly correct.

Trying to implement this highlighted a design choice that did not get articulated in my conversation with@mdehoon is mpl's idea of where the stale/invalid state should live is in scene graph tree or in the canvas. As I have implemented it, it lives in the scene graph, as@mdehoon wants it (and as it is explicitly implemented in macosx, explicitly as part ofdraw_idle in some backends, and deep in the guts of Qt currently) the state lives on the canvas side.

I think the arguments for doing this on the scene graph side are:

  • will work with backends we do not ship (I know of at least 2 in the wild)
  • will work with use-cases where the scene graph does not have a canvas associated with it (not relevant now, but pure export based work flows are coming).
  • requires changing less code

Although I admittedly have trouble coming up with a good use case, but forcing users into our idea of what the draw cadence should be seems wrong (but on the other hand, just turning interactive mode off seems to be the cut-out).

@mdehoon
Copy link
Contributor

@tacaswell Just for clarification,

in the case of macosx you deal with this by having an 'invalid' flag which the draw loop knows to mean it should re-draw on this cycle through

as it is explicitly implemented in macosx

There is no explicit 'invalid' flag in the macosx backend; currently draw_idle in the macosx backend simply calls canvas.invalidate(), which (in the C code) calls Apple's API function to schedule a redraw. There may be some 'invalid' flag hidden deep in Apple's libraries, but there is no explicit 'invalid' flag within matplotlib. In this sense it is similar to Qt.

Tkagg is different as it draws to _tkphoto, which then needs to be blitted explicitly.

This is the result of a phone discussion with @medhoonThe idea is to not rely on pyplot knowing to check if the figureneeds to be re-drawn, but just have the Figure object directlykick the canvas to draw_idle.This does not currently work with nbagg due to the first draw_idlebeing fired before it is finished building it's self.  There maybesimilar race conditions in the other backends.
@tacaswelltacaswellforce-pushed themnt_direct_call_draw_idle branch from2dcda03 toe048b12CompareAugust 15, 2015 02:55
@tacaswelltacaswell added this to theunassigned milestoneAug 15, 2015
@tacaswelltacaswell deleted the mnt_direct_call_draw_idle branchAugust 21, 2017 19:56
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@tacaswell@mdboom@mdehoon@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp