| Ticket UUID: | 7ebdd179743bf25e8b4533287ea214a83cadc498 | |||
| Title: | Yet another idle_curiosity feedback ticket | |||
| Type: | Bug | Version: | ||
| Submitter: | chrstphrchvz | Created on: | 2020-07-14 18:20:00 | |
| Subsystem: | (unused) | Assigned To: | marc_culler | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2020-09-01 19:54:59 | |
| Resolution: | None | Closed By: | marc_culler | |
| Closed on: | 2020-09-01 19:54:59 | |||
| Description: |
I would think the original ticket [06d8246baf] would be the ideal place to discuss idle_curiosity, but it has become quite lengthy. Here is my feedback separately so as to avoid derailing others' feedback tickets—unless it really does not belong in its own ticket. | |||
| User Comments: |
marc_culler (claiming to be Marc Culler) added on 2020-09-01 19:54:59:
I think this ticket can be closed since the idle_curiosity branch was merged quite a while ago. That is not to say that there are no more glitches related to the handling of idle tasks and interactions with [NSView drawRect:]. I just think that the useful life of this ticket is over. Feel free to reopen the ticket if necessary. marc_culler (claiming to be Marc Culler) added on 2020-07-16 22:41:20: I applied the hack and tried to see what would happen if event loops were
added to process idle events before each call to nextEventMatchingMask or
CFRunloopRunInMode (called in Tcl_WaitForEvent).
That did seem to eliminate all of the warnings except when resizing a window.
It seems that SetFrame has some different sort of access to drawRect when
liveResize is active.
It also introduced two new regression test failures in main.test. The error
was:
---- Test cleanup failed:
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"
While that could probably be addressed, I also don't see any specific benefit
from adding the extra event loops. I was not able to detect any difference in
behavior related to whether they are or are not present.
Maybe someone else will see something more revealing.
chrstphrchvz added on 2020-07-16 17:34:43: Here's small hack for checking for idle events without processing any: diff --git generic/tclTimer.c generic/tclTimer.c index 106e2f75aa..4e20097bc1 100644 --- generic/tclTimer.c +++ generic/tclTimer.c @@ -719,6 +719,9 @@ TclServiceIdle(void) if (tsdPtr->idleList == NULL) { return 0; } + if (getenv("TCL_IDLE_CHECK")) { + return 1; + }oldGeneration = tsdPtr->idleGeneration; tsdPtr->idleGeneration++; diff --git macosx/tkMacOSXWindowEvent.c macosx/tkMacOSXWindowEvent.c index 5f52ea742..7c29aadf1 100644 --- macosx/tkMacOSXWindowEvent.c +++ macosx/tkMacOSXWindowEvent.c @@ -919,6 +919,11 @@ ConfigureRestrictProc( fprintf(stderr, "drawRect: drawing %s in %s\n", Tk_PathName(winPtr), NSStringFromRect(rect).UTF8String); } + setenv("TCL_IDLE_CHECK", "1", 1); + if (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) { + fprintf(stderr, "Warning: idle event(s) queued when entering in drawRect\n"); + } + unsetenv("TCL_IDLE_CHECK"); #endif/* chrstphrchvz added on 2020-07-16 15:28:41: Marc, thanks once again for your patience. It could've been that in an attempt to not ramble for too long, I neglect to mention something important or phrase something unambiguously. A quick Google search for "setNeedsDisplay:NO" out of curiosity indicates that such usage should be fine or at least possible. I simply wasn't sure before, as from watching what happens when stepping into The now-removed first idle event loop I noticed in I've neglected to share here that the "Flash screen updates" feature in the Quartz Debug utility (from Additional Tools for Xcode) is useful for seeing when and where portions of a toplevel are redrawn. The "No delay after flash" is also useful; however I cannot use the "Flash identical screen updates" feature on the Mac I've been using (possibly because its graphics card isn't supported by Catalina). nab added on 2020-07-16 14:48:57: >Nicolas, does the current tip of idle_curiosity fix your issue? yes. cool ! would you mind to do a merge in stylish_idle_curiosity? thanks, ++ marc_culler (claiming to be Marc Culler) added on 2020-07-16 14:36:32: Oh. Now I get it. Sorry for being so dense, and thanks Christopher for explaining again. I pushed a new commit which, I believe, handles the test correctly. Nicolas, does the current tip of idle_curiosity fix your issue? chrstphrchvz added on 2020-07-16 11:56:51:
I had meant to say that any usage of nab added on 2020-07-16 09:24:27: as it may not be very clear, here's the video link: https://vimeo.com/438838089 nab added on 2020-07-16 09:00:34: a little bit more about window glitches now I've found a way to replicate them. please note that both checkins of yesterday suffers from this issue, and I've triple-check that checkin [7ac28ee6] does NOT suffer from this issue. here's the context, I've two toplevels on screen, the first one is displaying and updating a timer widget (a label) every seconds and the second one displaying a label in a tablelist. On the second one, I can keyPress Right key to generate events to update the label and if I hold the key, label is continuously updating. all that works fine. but if the label is updated at the same time that the timer of the first toplevel, I can see on the timer's toplevel (the first one) part of the screen of the second toplevel. And the glitches stays until the timer is updated again... I can make a video if you want. ++ nab added on 2020-07-16 07:27:31: Hi, with checkin https://core.tcl-lang.org/tk/info/87970183c0066afc, I see a lot of window glitches mainly when I deiconify toplevels. with checkin https://core.tcl-lang.org/tk/info/af841408b2fbd94a, I do not see such glitches. I used to create toplevel and withdraw it. now, with both checkins I need to create toplevel, withdraw it and update idletasks otherwise I can see them appearing/disappearing during a very short time. in terms of CPU, running a massive load in my app: https://core.tcl-lang.org/tk/info/af841408b2fbd94a = 60% of CPU https://core.tcl-lang.org/tk/info/87970183c0066afc = 50% of CPU ++ marc_culler (claiming to be Marc Culler) added on 2020-07-16 03:28:12: Thank you for the feedback Christopher. It does not seem to be possible to schedule calls to drawRect. Of course none of this is doucmented, but your observations indicated that it gets called from CFRunLoopRunInMode (called in Tcl_WaitForEvent) and from nextEventMatchingMask and no where else. So I have been assuming that if the needsDisplay flag is yes when either of those functions are called then drawRect will be run. I have seen no indication that this is wrong. The needsDisplay flag is a mutable boolean property, so there is no obstacle to assigning it either Boolean value. I agree that testing [NSView focusView] seems redundant and unnecessary and I found that I could remove those tests without causing any problems. Likewise I found that the needsRedisplay flag could be removed. That was an interesting question about whether the first event loop was needed. I found that I could remove that as well. But in experimenting with verious permutations of the code surrounding that loop I found that I was able to cause Tk_MapWindow to call XMapWindow with a window id of 0, which causes a segfault. So I added a guard against that and also removed the loop. I am sorry that I missed or forgot about your remark about wantsDefaultClipping. I had only tested on Catalina, but there are definitely reports of the same behavior on Mojave. So I edited that omment and th one about setFrame. And I added a call to NSRectFromCGRect. I also looked into the XSync function, which gets called by update after processing all events. I decided that there was no need for XXync to call tkMacOSXFlushWindows, and also no need for the generic ttk code to call it when the theme is changes. Since those were the only uses of it, I removcd that function. However, I did find that it happens (often in the test suite) that there can be timer tasks ready to run when XSync is called, presumably timers that fired while events were being processed in the update command. So I added an event loop which handles only timer events in XSync. After fixing a bug in listbox.test I now consistently get 0 failures in the regression tests on Catalina. chrstphrchvz added on 2020-07-14 18:20:11:
I am still trying to understand what's changed and whether some of the things that I was previously checking for as indicators of drawing problems still apply. This included idle events being queued when entering
I think of all this work will one day deserve an entry in macosx/README to give an idea of how macOS deferred drawing differs from what Tk can get away with on other platforms, when and why | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki