| Ticket UUID: | 7f0c0c9b82af1e9534273308bdac6adc29135a59 | |||
| Title: | Aqua refresh issues occur in several contexts | |||
| Type: | Bug | Version: | 8.6.11 | |
| Submitter: | marc_culler | Created on: | 2021-01-15 20:23:29 | |
| Subsystem: | 64. Graphic Contexts | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2021-05-04 22:22:19 | |
| Resolution: | Fixed | Closed By: | marc_culler | |
| Closed on: | 2021-05-04 22:22:19 | |||
| Description: |
This ticket is a request for review, testing and comments on a branch off of core-8-6-branch named mac_lockfocus. Since the dark days of Mojave there have been several tickets reporting situations where some component of a widget does not get redrawn when it should. These include [2a61eca3a8], [f79ed9db4a], [fa1a4cfa2a], and a recent report by Steve Lander on the core list about notebook tabs. Also, [685ac30727] is related. With the Mojave release the [NSView lockFocus] method was deprecated. Apple's intent was that drawing should only be done from within the [NSView drawRect] method, which is always called after the NSView has been targeted as the current drawing context, which is what the lockFocus method does. Tk was significantly reorganized to attempt to arrange that all drawing be done in the [NSView drawRect] method, even though this does not fit perfectly with the design of Tk. Mostly this works. The situations where the drawing does not get done tend to be complex, hence hard to debug. They also show signs of the presence of a race condition that can lead to redraw failures if the wrong horse wins. For ticket [2a61eca3a8] Nicolas produced a now famous script which creates a canvas containing 100 rectangles which are repainted in a rolling pattern with timer events. Steve Landers produced an example script, which I will attach to this ticket, that shows notebook tabs not getting displayed as selected tabs the first time that the tab is selected. This script requires both the tablelist package and the scrollutils package and, for example, not using scrollutils makes the refresh issue disappear. Similarly, running the full script in valgrind, which will change timings somewhat, makes the artifact disappear. With both of these sample scripts I have set up logging to see what could be happening and in both cases what I see is that the drawing procedure which does not do its job does, in fact, get called and it gets called from the drawRect method and when it does get called the current graphics context has a clipping region which should allow the drawing to take place. As far as I can see, whatever the race condition that is causing this problem may be, it appears to be outside of Tk. The mac_lockfocus branch appears to make both the notebook and the 100-rectangle scripts work correctly. I think it will also fix [f79ed9db4a] although I cannot test that since I was never able to reproduce the issue (which is consistent with the race condition hypothesis). There is a catch, which is that in order to get the benefit of the (small) change in that branch, Tk must be compiled with a minimum OS version target which is earlier than 10.14. Calling [NSView lockFocus] does not raise a deprecation warning if the minimum OS version target is less than 10.14. And what is done in that branch, with conditional code that requires a minimum target less than 10.14, is that whenever drawing is attempted within a TKContentView which does not have the graphics focus, the lockFocus method of the view is called. At the end of the drawing, the unlockFocus method is called if the lockFocus method had been called at the beginning, as is required. The new branch passes all tests although for the debug (Development) version there are some warnings about failures of certain HITheme functions. | |||
| User Comments: |
marc_culler (claiming to be Marc Culler) added on 2021-05-04 22:22:19:
As far as I can tell, these problems were all resolved by switching to an explicit CALayer-backed view for the TKContentView. Without that, there were just occasions when drawing would fail. It had nothing to do with event loops or event processing or drawing in or out of drawRect. Drawing was not happening when it should. Now it does happen. So I can finally close this ticket. stevel added on 2021-01-20 08:17:09: Christopher, you can see the bug at occuring at https://www.dropbox.com/s/hy6rqdq7qpq9ubu/bug.m4v?dl=0. This shows the display from the script that Marc attached. If you click on Tab E you’ll see the contents of the tab change but the tab label itself doesn’t. A second click on Tab E and the tab text now refreshes. Click on Tab E initially then move the cursor out of the tab label and it will refresh. This is using the core-8-6 branch on Big Sur. chrstphrchvz added on 2021-01-17 14:25:43: I would compare the new work to what existed prior to [cf6f5ebe44] for other ideas. For example, would it be better to restore the lockedFocus member of TkMacOSXDrawingContext than to introduce a global variable? chrstphrchvz added on 2021-01-17 13:28:06: [87d589d585] did not resolve [f79ed9db4a] for me. I suggest using:
if ([view lockFocusIfCanDraw]) {
…
instead of:
if ([view canDraw]) {
[view lockFocus];
…
chrstphrchvz added on 2021-01-17 12:53:51: For reference, could someone please link to the discussion regarding the notebook tabs issue? I have not located it myself. I have not managed to reproduce any issues with the tst.tcl script using latest core-8-6-branch ([c4d94408e0]) on macOS 10.13 High Sierra nor 10.15 Catalina on my MacBook Pro 2010 13 inch. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki