From: Kevin W. <kw...@co...> - 2015-03-08 04:59:59
|
Hello all, I've done some additional work with the old Tk-Cocoa event loop bug reported here: http://core.tcl.tk/tk/tktview/3028676fffffffffffffffffffffffffffffffff and I have developed what may be a fix, or at least an improvement. Please see the entire comment thread at the bug report for context and background, as well as some test scripts that illustrate the bug, but here is my comment below: --- I've been doing some additional experimentation with this, and this diff of tclMacOSXNotify.c in trunk seems to improve things significantly in terms of avoiding hangs: --- tclMacOSXNotify-current.c 2015-03-07 23:31:56.000000000 -0500 +++ tclMacOSXNotify.c 2015-03-07 23:41:21.000000000 -0500 @@ -1412,7 +1412,8 @@ (tsdPtr->runLoopNestingLevel > 1 || !tsdPtr->runLoopRunning)) { tsdPtr->runLoopServicingEvents = 1; - while (Tcl_ServiceAll() && tsdPtr->waitTime == 0) {} + /* This call seems to simply force event processing through and prevents hangups that have long been observed with Tk-Cocoa. */ + Tcl_ServiceAll(); tsdPtr->runLoopServicingEvents = 0; } break; In brief, swapping out the while loop and replacing it with a direct call to Tcl_ServiceAll() just seems to force things through. The demo script attached to this bug (beachball-bug.tcl) does not lock up, although resizing the window and selecting menus does run a bit sluggishly until the events are processed. The shorter script referenced elsewhere here does not freeze at all with this change. I see this as a promising fix for this bug, and a way to further reduce the issues with the event loop, but I would like others to test as well and see if their experiences match mine. --- I would be very grateful if others who have had issues with the event loop could try this patch (the file is in tcl/macosx) as soon as possible and try it out against whatever code you find triggers major hangs in Tk-Cocoa. As I understand the notifier code, this particular code only runs when the Tcl notifier is in embedded mode, cf. in Tk-Cocoa, and not in pure Tcl, so it is not likely to be demonstrated by the Tcl test suite. Daniel Steffen advised that any changes to the notifier code would need to be exercised in Tk, either via the test suite or by running the Tk demo code (my preferred method). Running the Wish demo, things seem to work just fine. If others report that this code seems to remove or reduce the major issues with Tk's event loop, I will commit it to trunk, backport it to 8.5, and may even want to do an updated release of 8.5.18 (I know this is a bit late, but it's so critical that I would want to push it out). If others report no improvement, then I'll leave the code as is. Again, please test this as soon as possible, and if it works for you, I'll commit it right away. Thanks, Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |