| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@xzores can you install matplotlib from this PR and see if it prevents your crashes? pip install git+https://github.com/richardsheridan/matplotlib.git@tk_blit_thread_safe |
Sorry, something went wrong.
I found another way. I don't really want to undo my code, so I will have no way to test. |
Sorry, something went wrong.
|
I'm always happy to be wrong about this sort of thing 😄 I assume that mpl_tk_blit can go away now? |
Sorry, something went wrong.
|
Indeed, this appears to work. But I think the logic should go into _backend_tk.blit instead, so that it also works for tkcairo (and mplcairo.tk :))? |
Sorry, something went wrong.
|
It was a bit tricky to ensure that the right arguments connect with the right call to _tkagg.blit. Unfortunately PhotoImage is a kind of incomplete widget that doesn't have a register method or parent widget attribute, so it is necessary to pass in some other, unrelated widget.If anyone can think of a smarter way to get to the root widget, I'm open to it! nm i thought of one |
Sorry, something went wrong.
|
My test creates some stderr spam from a ttk widget being destroyed late, but I can't for the life of me figure out how to fix it. It would also be nice to get coverage on the code where bbox is not none, but I don't think it should block this PR. |
Sorry, something went wrong.
|
The stderr spam will probably look familiar to some: can't invoke "event" command: application has been destroyed
while executing
"event generate $w <<ThemeChanged>>"
(procedure "ttk::ThemeChanged" line 6)
invoked from within
"ttk::ThemeChanged"
It can be silenced by adding an update_idletasks as per #9956 but I will try a bit more to see if we can avoid that route. |
Sorry, something went wrong.
|
Some interesting failures on travis. I'm not sure what webagg has to do with anything, but some segfaults happen on py38 that don't happen on py37. Possibly I can guard that section of the test from running on the deprecated backend = 'wx'? |
Sorry, something went wrong.
current status: doesn't crash but also doesn't draw when called from a thread
current status: Prone to races and hard-to-diagnose timeouts (see python/cpython#21299)
current status: Relies on tkinter arcana, untested
current status: Relies on tkinter arcana, untested
drawing from a thread produces an intolerable flicker unless blank and blit are called from the same event in the main thread
|
@tacaswell @anntzer This PR is consistently green on CI now, if you want to have another look. I left it up to some other enterprising hacker to fix wx or macosx if they need it and make a separate PR. |
Sorry, something went wrong.
|
|
||
| _blit_args = {} | ||
| # Initialize to a non-empty string that is not a Tcl command | ||
| _blit_tcl_name = "29345091836409813" |
There was a problem hiding this comment.
why not directly initialize this to the final name here? e.g. "mpl_blit_" + uuid.uuid4().hex
Sorry, something went wrong.
There was a problem hiding this comment.
I love this idea, I always thought the initial name was tacky but for some reason I never came up with this fix!
Sorry, something went wrong.
There was a problem hiding this comment.
Just a quick question, didn't we have a bug report come by recently because we were using one of the uuid functions, which was using a "weak" shasum algorithm, so their security-restricted system couldn't compute it?
Sorry, something went wrong.
There was a problem hiding this comment.
In a pinch we could hardcode a uuid, they are universally unique after all...
Sorry, something went wrong.
|
Just some minor points, but mostly looks good. |
Sorry, something went wrong.
There was a problem hiding this comment.
conditional on handling the comments above.
Sorry, something went wrong.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
PR Summary
Closes #13293. (possibly?) Use tk.call to invoke tkinter's cross-thread signalling when necessary to safely blit from threads. A small amount of architectural changes were made in the hopes of attaining actual CPU parallelism with threads, but that was unsuccessful because of how Tk_PhotoPutBlock is written upstream.
Nevertheless this will prevent some silent crashes.
Downsides: I haven't done any work to prevent data races, and users that misuse the Tcl event system may run into issues discussed in python/cpython#21299
Needs a test.
PR Checklist