From: Kevin W. <kw...@co...> - 2014-07-25 18:32:28
|
Hi all, I'm writing to report on a couple of significant commits I have made to Tk/Mac on both trunk and core-8-5-branch. The first commit is based on an extensive patch provided by Marc Culler that fixes alpha rendering in images under Tk Cocoa; some changes in 10.9 Mavericks broke rendering of the alpha channel in images, so transparency was no longer displayed (instead just ugly black shapes for shadows, or nothing at all). Marc re-worked several functions to restore this functionality, and I appreciate his work. Thanks so much to him for taking the time to submit, re-work, and then re-submit the patch. The second change involves removing several function calls into private, undocumented Cocoa drawing methods. Some of these changes may be a bit controversial, as they carry a performance penalty in certain contexts, but I believe they are important and I wanted to explain why I have made them. As designed, Tk Cocoa attempts to map an X11 style of window drawing onto the Cocoa graphics/windowing API. We're all aware that this is not a seamless mapping. To improve the drawing performance and make the rendering a bit cleaner, Daniel Steffen borrowed some techniques from WebKit that involve calling into private, undocumented API's to give Tk better, more fine-grained control of drawing in response to X11-style "Expose" events. Apple has always warned against using undocumented API's as they are unsupported and subject to change. However, in 2009, when Daniel was working on the Cocoa port, this seemed a very reasonable optimization to make, as the example of WebKit was already out there, and the relevant private API's had not been changed for several years. Also, Apple did not take any action against accessing private API's beyond discouraging it as unsupported and occasionally changing the API's in question. More recently, however, Apple has taken a harder line on using undocumented API's by making it more difficult to distribute apps that make use of such calls; these apps are not allowed in the Mac App Store, which has become the main way of distributing apps on the Mac platform. For instance, in the case of my own apps, this has prevented me from shipping up-to-date Tk code with my apps, because the app store restrictions forbid it. I have worked around the issue by linking to the version of Tk bundled with the operating system, which on my machine is 8.5.9. (This loophole exists because Apple-installed libraries are exempted from their rules on private API's.) Such workarounds are inherently fragile, however, as they are dependent on Apple continuing to ship Tk with the operating system. If Apple were to stop distributing Tk with OS X, then no app making use of Tk as currently designed would be able to access Apple's main distribution channel. These changes in the Mac platform, combined with my general discomfort with Tk accessing unsupported API's when other open-source languages and frameworks do not, have led me to conclude that these calls need to be removed. And that's what I've done. In some cases, the removal of these calls causes no issue at all. A few of the calls focused on accessing the "resize grip" on the lower corner of a window. Apple removed the "resize grip" from windows in 10.7, so there is no need for private API access here at all. In other cases, there may be a performance hit in drawing especially complex interfaces. I commented out an entire class designed by Daniel that accesses private NSWindow/NSView API's, based on the example of WebKit. My initial fear was that this would prevent drawing from occurring at all, but that's not the case. I've done a fair amount of testing with the widget demo, my own apps, and a couple of third-party apps that link to Tk, and in virtually every context windows and widgets draw as expected and with no noticeable change in rendering. Images display fine, buttons work as expected, and text scrolls without any delay. Redraw of the window in response to resizing also works OK. The one area where I did notice a significant difference was in the widget demo where a text widget is drawn with a large number of embedded widgets, buttons, etc. There is lag in drawing the widgets when the text is scrolled. Unfortunately, I haven't found any way to replace the calls to private API's with equally optimized public API's; I assume that's why the private calls are there in the first place. Because I've only found very limited cases of regression in the drawing performance, I am willing to accept these in the service of removing the calls to private API's. The private API access simply places unacceptable limitations on distributing any app linking to Tk on the Mac, and more generally gives Apple too much control over Tk's functionality; calling private API's is not a good foundation for a GUI toolkit. I've made the commits to core-8-5-branch in time for these changes to make it into the upcoming release of Tcl/Tk 8.5.16, and whenever a new release of 8.6 is made. Let me know if you have questions or concerns. Thanks, Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Steve L. <st...@di...> - 2014-07-26 00:51:19
|
Kevin, This all makes sense to me. Thanks to you and Marc for for initiating the work and stewarding it to completion. Steve > On 26 Jul 2014, at 2:32 am, Kevin Walzer <kw...@co...> wrote: > > Hi all, > > I'm writing to report on a couple of significant commits I have made to > Tk/Mac on both trunk and core-8-5-branch. > > The first commit is based on an extensive patch provided by Marc Culler > that fixes alpha rendering in images under Tk Cocoa; some changes in > 10.9 Mavericks broke rendering of the alpha channel in images, so > transparency was no longer displayed (instead just ugly black shapes for > shadows, or nothing at all). Marc re-worked several functions to restore > this functionality, and I appreciate his work. Thanks so much to him for > taking the time to submit, re-work, and then re-submit the patch. > > The second change involves removing several function calls into private, > undocumented Cocoa drawing methods. Some of these changes may be a bit > controversial, as they carry a performance penalty in certain contexts, > but I believe they are important and I wanted to explain why I have made > them. > > As designed, Tk Cocoa attempts to map an X11 style of window drawing > onto the Cocoa graphics/windowing API. We're all aware that this is not > a seamless mapping. To improve the drawing performance and make the > rendering a bit cleaner, Daniel Steffen borrowed some techniques from > WebKit that involve calling into private, undocumented API's to give Tk > better, more fine-grained control of drawing in response to X11-style > "Expose" events. > > Apple has always warned against using undocumented API's as they are > unsupported and subject to change. However, in 2009, when Daniel was > working on the Cocoa port, this seemed a very reasonable optimization to > make, as the example of WebKit was already out there, and the relevant > private API's had not been changed for several years. Also, Apple did > not take any action against accessing private API's beyond discouraging > it as unsupported and occasionally changing the API's in question. > > More recently, however, Apple has taken a harder line on using > undocumented API's by making it more difficult to distribute apps that > make use of such calls; these apps are not allowed in the Mac App Store, > which has become the main way of distributing apps on the Mac platform. > For instance, in the case of my own apps, this has prevented me from > shipping up-to-date Tk code with my apps, because the app store > restrictions forbid it. > > I have worked around the issue by linking to the version of Tk bundled > with the operating system, which on my machine is 8.5.9. (This loophole > exists because Apple-installed libraries are exempted from their rules > on private API's.) Such workarounds are inherently fragile, however, as > they are dependent on Apple continuing to ship Tk with the operating > system. If Apple were to stop distributing Tk with OS X, then no app > making use of Tk as currently designed would be able to access Apple's > main distribution channel. > > These changes in the Mac platform, combined with my general discomfort > with Tk accessing unsupported API's when other open-source languages and > frameworks do not, have led me to conclude that these calls need to be > removed. And that's what I've done. > > In some cases, the removal of these calls causes no issue at all. A few > of the calls focused on accessing the "resize grip" on the lower corner > of a window. Apple removed the "resize grip" from windows in 10.7, so > there is no need for private API access here at all. > > In other cases, there may be a performance hit in drawing especially > complex interfaces. I commented out an entire class designed by Daniel > that accesses private NSWindow/NSView API's, based on the example of > WebKit. My initial fear was that this would prevent drawing from > occurring at all, but that's not the case. I've done a fair amount of > testing with the widget demo, my own apps, and a couple of third-party > apps that link to Tk, and in virtually every context windows and widgets > draw as expected and with no noticeable change in rendering. Images > display fine, buttons work as expected, and text scrolls without any > delay. Redraw of the window in response to resizing also works OK. The > one area where I did notice a significant difference was in the widget > demo where a text widget is drawn with a large number of embedded > widgets, buttons, etc. There is lag in drawing the widgets when the text > is scrolled. Unfortunately, I haven't found any way to replace the calls > to private API's with equally optimized public API's; I assume that's > why the private calls are there in the first place. > > Because I've only found very limited cases of regression in the drawing > performance, I am willing to accept these in the service of removing the > calls to private API's. The private API access simply places > unacceptable limitations on distributing any app linking to Tk on the > Mac, and more generally gives Apple too much control over Tk's > functionality; calling private API's is not a good foundation for a GUI > toolkit. > > I've made the commits to core-8-5-branch in time for these changes to > make it into the upcoming release of Tcl/Tk 8.5.16, and whenever a new > release of 8.6 is made. > > Let me know if you have questions or concerns. > > Thanks, > Kevin > > -- > Kevin Walzer > Code by Kevin/Mobile Code by Kevin > http://www.codebykevin.com > http://www.wtmobilesoftware.com > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core |
From: Jeff H. <je...@ac...> - 2014-07-26 18:09:55
|
+1 from me as well, and thanks for the efforts. On Fri, Jul 25, 2014 at 5:33 PM, Steve Landers <st...@di...> wrote: > Kevin, > > This all makes sense to me. Thanks to you and Marc for for initiating the work and stewarding it to completion. > > Steve > >> On 26 Jul 2014, at 2:32 am, Kevin Walzer <kw...@co...> wrote: >> >> Hi all, >> >> I'm writing to report on a couple of significant commits I have made to >> Tk/Mac on both trunk and core-8-5-branch. >> >> The first commit is based on an extensive patch provided by Marc Culler >> that fixes alpha rendering in images under Tk Cocoa; some changes in >> 10.9 Mavericks broke rendering of the alpha channel in images, so >> transparency was no longer displayed (instead just ugly black shapes for >> shadows, or nothing at all). Marc re-worked several functions to restore >> this functionality, and I appreciate his work. Thanks so much to him for >> taking the time to submit, re-work, and then re-submit the patch. >> >> The second change involves removing several function calls into private, >> undocumented Cocoa drawing methods. Some of these changes may be a bit >> controversial, as they carry a performance penalty in certain contexts, >> but I believe they are important and I wanted to explain why I have made >> them. >> >> As designed, Tk Cocoa attempts to map an X11 style of window drawing >> onto the Cocoa graphics/windowing API. We're all aware that this is not >> a seamless mapping. To improve the drawing performance and make the >> rendering a bit cleaner, Daniel Steffen borrowed some techniques from >> WebKit that involve calling into private, undocumented API's to give Tk >> better, more fine-grained control of drawing in response to X11-style >> "Expose" events. >> >> Apple has always warned against using undocumented API's as they are >> unsupported and subject to change. However, in 2009, when Daniel was >> working on the Cocoa port, this seemed a very reasonable optimization to >> make, as the example of WebKit was already out there, and the relevant >> private API's had not been changed for several years. Also, Apple did >> not take any action against accessing private API's beyond discouraging >> it as unsupported and occasionally changing the API's in question. >> >> More recently, however, Apple has taken a harder line on using >> undocumented API's by making it more difficult to distribute apps that >> make use of such calls; these apps are not allowed in the Mac App Store, >> which has become the main way of distributing apps on the Mac platform. >> For instance, in the case of my own apps, this has prevented me from >> shipping up-to-date Tk code with my apps, because the app store >> restrictions forbid it. >> >> I have worked around the issue by linking to the version of Tk bundled >> with the operating system, which on my machine is 8.5.9. (This loophole >> exists because Apple-installed libraries are exempted from their rules >> on private API's.) Such workarounds are inherently fragile, however, as >> they are dependent on Apple continuing to ship Tk with the operating >> system. If Apple were to stop distributing Tk with OS X, then no app >> making use of Tk as currently designed would be able to access Apple's >> main distribution channel. >> >> These changes in the Mac platform, combined with my general discomfort >> with Tk accessing unsupported API's when other open-source languages and >> frameworks do not, have led me to conclude that these calls need to be >> removed. And that's what I've done. >> >> In some cases, the removal of these calls causes no issue at all. A few >> of the calls focused on accessing the "resize grip" on the lower corner >> of a window. Apple removed the "resize grip" from windows in 10.7, so >> there is no need for private API access here at all. >> >> In other cases, there may be a performance hit in drawing especially >> complex interfaces. I commented out an entire class designed by Daniel >> that accesses private NSWindow/NSView API's, based on the example of >> WebKit. My initial fear was that this would prevent drawing from >> occurring at all, but that's not the case. I've done a fair amount of >> testing with the widget demo, my own apps, and a couple of third-party >> apps that link to Tk, and in virtually every context windows and widgets >> draw as expected and with no noticeable change in rendering. Images >> display fine, buttons work as expected, and text scrolls without any >> delay. Redraw of the window in response to resizing also works OK. The >> one area where I did notice a significant difference was in the widget >> demo where a text widget is drawn with a large number of embedded >> widgets, buttons, etc. There is lag in drawing the widgets when the text >> is scrolled. Unfortunately, I haven't found any way to replace the calls >> to private API's with equally optimized public API's; I assume that's >> why the private calls are there in the first place. >> >> Because I've only found very limited cases of regression in the drawing >> performance, I am willing to accept these in the service of removing the >> calls to private API's. The private API access simply places >> unacceptable limitations on distributing any app linking to Tk on the >> Mac, and more generally gives Apple too much control over Tk's >> functionality; calling private API's is not a good foundation for a GUI >> toolkit. >> >> I've made the commits to core-8-5-branch in time for these changes to >> make it into the upcoming release of Tcl/Tk 8.5.16, and whenever a new >> release of 8.6 is made. >> >> Let me know if you have questions or concerns. >> >> Thanks, >> Kevin >> >> -- >> Kevin Walzer >> Code by Kevin/Mobile Code by Kevin >> http://www.codebykevin.com >> http://www.wtmobilesoftware.com |
From: Kevin W. <kw...@co...> - 2014-07-28 02:55:58
|
Jeff (and Donal and Steve and Gustaf and Will), On 7/26/14, 1:40 PM, Jeff Hobbs wrote: > +1 from me as well, and thanks for the efforts. Thanks for the vote of confidence. It means a lot. FWIW, I've done a bit more fine-tuning of the code, removing the private calls altogether rather than just ifdefing them out. I also found and removed a bottleneck that was displaying atrociously slow redraw of complex interfaces when scrolling (i.e. the text widget with embedded windows from the demo); now I think the performance is almost indistinguishable from the previous implementation that used the private interfaces. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Don P. <d.g...@co...> - 2014-07-29 04:02:50
|
On Jul 25, 2014, at 2:32 PM, Kevin Walzer <kw...@co...> wrote: > I'm writing to report on a couple of significant commits I have made to > Tk/Mac on both trunk and core-8-5-branch. From the descriptions, all sounds good to me. Prompted by the substantial work, I gave the Tk test suite a try on my Mavericks MacBook Pro. The results were … interesting. Can you comment on what we ought to expect from the Tk test suite? I know it’s never played the same central role on OSX as it has on other platforms, but at one point we did at least reach the point where the test suite did not crash or hang. I’m seeing what looks like panics from system libraries? Perhaps just trying the test suite yourself will point the way to further improvements? DGP |
From: Kevin W. <kw...@co...> - 2014-07-29 13:22:49
|
On 7/29/14, 12:02 AM, Don Porter wrote: > Prompted by the substantial work, I gave the Tk test suite a try > on my Mavericks MacBook Pro. The results were … interesting. > > Can you comment on what we ought to expect from the Tk test suite? > I know it’s never played the same central role on OSX as it has on > other platforms, but at one point we did at least reach the point > where the test suite did not crash or hang. > > I’m seeing what looks like panics from system libraries? Perhaps > just trying the test suite yourself will point the way to further > improvements? > I've never been quite sure how to use the test suite as a benchmarking tool, as I see it (at least on Mac) reporting failures with no apparent issues for how Tk runs. I observed this with the 8.5 suite incorporating the recent commits: Tests ended at Tue Jul 29 08:24:28 EDT 2014 all.tcl: Total 457 Passed 432 Skipped 14 Failed 11 Sourced 17 Test Files. Files with failing tests: entry.test spinbox.test ttk.test Number of tests skipped for each constraint: 2 NA 4 coreEntry 5 nyi 3 xpnative Kevins-MacBook-Pro:tcl-tk-85-main-merge kevin$ Running the suite against 8.6, I did observe a crash: 0 Tk 0x00000001007c463f TkPointerEvent + 1327 (tkGrab.c:889) 1 Tk 0x00000001007b5030 InvokeMouseHandlers + 176 (tkEvent.c:299) 2 Tk 0x00000001007b46ec Tk_HandleEvent + 332 (tkEvent.c:1276) 3 Tk 0x000000010079f68e HandleEventGenerate + 7230 (tkBind.c:3440) Seems to be an issue with the mouse pointer--if it's in the grab code, Tk-Cocoa's event loop doesn't play well with grab and I tend to discourage its use. I'm not sure where in the test suite this came; here is the output from the test commands themselves: ==== textIndex-19.12 Display lines FAILED ==== Contents of test case: .t index "2.40 -1displaylines" ---- Result was: 2.17 ---- Result should have been (exact matching): 2.20 ==== textIndex-19.12 FAILED textMark.test textTag.test 2014-07-29 09:07:17.987 tktest[33359:507] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: badStipple 2014-07-29 09:07:17.989 tktest[33359:507] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: bogus /bin/sh: line 1: 33359 Segmentation fault: 11 ./tktest /Users/kevin/tcl-tk-fossil/tk/unix/../tests/all.tcl -geometry +0+0 make[2]: *** [test-classic] Error 139 make[1]: *** [test-tk] Error 2 make: *** [test-develop] Error 2 Any idea where I could take a closer look at this? --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Russell E. O. <ro...@uw...> - 2014-08-08 18:05:13
|
In article <53D...@co...>, Kevin Walzer <kw...@co...> wrote: > Jeff (and Donal and Steve and Gustaf and Will), > > On 7/26/14, 1:40 PM, Jeff Hobbs wrote: > > +1 from me as well, and thanks for the efforts. > > Thanks for the vote of confidence. It means a lot. > > FWIW, I've done a bit more fine-tuning of the code, removing the private > calls altogether rather than just ifdefing them out. I also found and > removed a bottleneck that was displaying atrociously slow redraw of > complex interfaces when scrolling (i.e. the text widget with embedded > windows from the demo); now I think the performance is almost > indistinguishable from the previous implementation that used the private > interfaces. Wow! I was going to say how pleased I was that you removed the private calls, but this makes it even better. Thank you very much for the cleanups. -- Russell |