<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 12, 2018 at 7:38 PM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi John,<div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 12, 2018 at 1:46 PM John McIntosh <<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Ok, well this code comes from the original implementation in 2010. </div><div dir="ltr"><br><div>What it is doing is priming the sound system, by starting up the sound api, feeding it silence, then stopping it. </div><div>It was written so that the sound plugin was ready to go when someone used the soundPlugin. </div><div>A 500 ms pause on just the first use of sound drove certain musically inclined folks crazy.  As you saw "<span style="font-size:12.800000190734863px">appalling startup performance"</span></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Actually I think this is Apple's regression and Apple's bug.  I see a similar performance regression in Safari.  Open a new tab.  Do a search in the URL fields.  First, one sees the meatball cursor.  Subsequently one cannot click any of the links for several seconds.  This is on Safari Version 12.0 (13606.2.11), macOS High Sierra Version 10.13.6.  Does anyone else see this or is my system in some strange state?</div></div></div></div></div></blockquote><div><br></div><div>Indeed, fixed by a reboot.  This is some weird state the sound system gets into when switching between an Apple cinema display, some bluetooth headphones/microphones and AirPlay.  Sorry about the noice.</div><div><br></div><div>So John, if I understand correctly the code in the VM does actually cause a 0.5 second startup delay.  That's, um, undesirable, to say the least.  I agree that we should fix this but is the complexity you outline below necessary?  Isn't there some kind of sound reset call in the API?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><div class="gmail_quote"><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>What could be change by someone with the will to write a bit of code, (then test) is to fork off the sound setup message by sending then  "<font color="#31595d" face="Menlo">setupSoundLogic" </font>(or maybe separate out the logic after the creation of the soundInterfaceLogic)<span style="font-size:13px;color:rgb(79,129,135);font-family:Menlo"> </span>on a worker thread, then have a guard mutex on the accessor <span style="font-size:13px;color:rgb(79,129,135);font-family:Menlo">soundInterfaceLogic </span>(just add a explicit soundInterfaceLogic accessor to sqSqueakOSXApplication)<span style="font-size:13px;color:rgb(79,129,135);font-family:Menlo"> </span>so that a call to the OSX soundPlugin like <span style="font-size:13px;color:rgb(0,0,0);font-family:Menlo">soundInit </span>can not complete until we have fully created the <span style="font-size:13px;color:rgb(79,129,135);font-family:Menlo">sqSqueakSoundCoreAudio </span>instance.   Perhaps the use of  <span style="font-size:13px;color:rgb(186,45,162);font-family:Menlo">@synchronized</span><span style="font-size:13px;font-family:Menlo;color:rgb(0,0,0)">(</span><span style="font-size:13px;color:rgb(79,129,135);font-family:Menlo">soundInterfaceLogic) {}</span><br></div><div><br></div><div>This all assumes use of any platform API can be done on a worker thread versus the main thread.</div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 11, 2018 at 9:41 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>    it seems due to this code:</div><div><br></div><div><div>frame #29: 0x0015358c Squeak`-[sqSqueakOSXApplication setupSoundLogic](self=0x02408810, _cmd="setupSoundLogic") + 412 at sqSqueakOSXApplication.m:152</div><div>   149 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">           </span>snd_Start(2644, 22050, 1, 0);</div><div>   150 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">             </span>char silence[10576];</div><div>   151 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">              </span>bzero(&silence, sizeof(silence));</div><div>-> 152 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">            </span>snd_PlaySamplesFromAtLength(2644,(usqInt * ) &silence,0);</div><div>   153 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">             </span>[self.soundInterfaceLogic snd_Stop_Force];</div><div>   154 <span class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div>   155</div></div><div><br></div><div>who wrote it?  Surely there's a better way of ensuring the sound system is in a silent way...</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 11, 2018 at 9:36 PM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>    in building new VMs today I see appalling startup performance on Mac OS X.  It seems to be related to event setup and/or sound initialization.  I ran under a debugger and interrupted while the system was (slowly) launching and both times I saw a similar stack; see below.  So the system looks to be caught in some kind of initialization loop:</div><div><br></div><div><div>    frame #7: 0x9331ff16 CoreAudio`HALC_ShellSimpleProxyList::Reconcile(bool, bool) + 646</div><div>    frame #8: 0x9331f569 CoreAudio`HALC_ShellPlugIn::ConnectToServer() + 153</div><div>    frame #9: 0x9338904e CoreAudio`HAL_HardwarePlugIn_InitializeWithObjectID(AudioHardwarePlugInInterface**, unsigned long) + 78</div><div>    frame #10: 0x9331d818 CoreAudio`HALPlugIn::Initialize() + 48</div><div>    frame #11: 0x9331c3a0 CoreAudio`HALPlugInManagement::CreateHALPlugIn(HALCFPlugIn const*) + 2048</div><div>    frame #12: 0x9331ac08 CoreAudio`HALPlugInManagement::Initialize() + 552</div><div>    frame #13: 0x93317070 CoreAudio`HALSystem::CheckOutInstance() + 190</div><div>    frame #14: 0x9331e4bb CoreAudio`AudioObjectGetPropertyData + 81</div><div>    frame #15: 0x92643947 AudioToolbox`AQMEIO_HAL::Init() + 201</div><div>    frame #16: 0x92643132 AudioToolbox`AQMEIOManager::_FindIOUnit(__CFString const*) + 110</div><div>    frame #17: 0x92642f23 AudioToolbox`AQMEDevice::InitPhase2(__CFString const*) + 239</div><div>    frame #18: 0x92642e2e AudioToolbox`AQMixEngine_Single::InitPhase2() + 24</div><div>    frame #19: 0x92642a34 AudioToolbox`AQIONodeManager::_FindAQIONode(bool, __CFString const*) + 154</div><div>    frame #20: 0x926426a9 AudioToolbox`AudioQueueObject::DoIONodeConnect(bool) + 963</div><div>    frame #21: 0x92715bfe AudioToolbox`AudioQueueObject::GetIONodeConnection_Init(long&) + 40</div><div>    frame #22: 0x9270b7c6 AudioToolbox`AudioQueueObject::GetConverterConnection_Init(long&) + 20</div><div>    frame #23: 0x9265a77b AudioToolbox`AudioQueueObject::AcquirePlayResources() + 215</div><div>    frame #24: 0x92709095 AudioToolbox`AudioQueueObject::Prime(unsigned long, unsigned long&) + 345</div><div>    frame #25: 0x9265a571 AudioToolbox`AQServer_Prime + 95</div><div>    frame #26: 0x9265a43d AudioToolbox`AudioQueuePrime + 364</div><div>    frame #27: 0x0021c841 Squeak`-[sqSqueakSoundCoreAudio snd_PlaySamplesFromAtLength:arrayIndex:startIndex:](self=0x0262e990, _cmd="snd_PlaySamplesFromAtLength:arrayIndex:startIndex:", frameCount=2644, arrayIndex="", startIndex=0) + 481 at sqSqueakSoundCoreAudio.m:319</div><div>    frame #28: 0x0021ed8d Squeak`snd_PlaySamplesFromAtLength(frameCount=2644, arrayIndex=0xbfffb588, startIndex=0) + 125 at sqSqueakSoundCoreAudioAPI.m:62</div><div>    frame #29: 0x0015358c Squeak`-[sqSqueakOSXApplication setupSoundLogic](self=0x02408810, _cmd="setupSoundLogic") + 412 at sqSqueakOSXApplication.m:152</div><div>    frame #30: 0x0016b5c9 Squeak`-[sqSqueakMainApplication runSqueak](self=0x02408810, _cmd="runSqueak") + 617 at sqSqueakMainApplication.m:198</div><div>    frame #31: 0x95216299 Foundation`__NSFirePerformWithOrder + 432</div><div>    frame #32: 0x9379a496 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 22</div><div>    frame #33: 0x9379a3b2 CoreFoundation`__CFRunLoopDoObservers + 498</div><div>    frame #34: 0x9377d7fd CoreFoundation`__CFRunLoopRun + 1661</div><div>    frame #35: 0x9377ce51 CoreFoundation`CFRunLoopRunSpecific + 641</div><div>    frame #36: 0x9377cbba CoreFoundation`CFRunLoopRunInMode + 122</div><div>    frame #37: 0x92d7a37b HIToolbox`RunCurrentEventLoopInMode + 321</div><div>    frame #38: 0x92d79f5f HIToolbox`ReceiveNextEventCommon + 454</div><div>    frame #39: 0x92d79d7b HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71</div><div>    frame #40: 0x9137ab2d AppKit`_DPSNextEvent + 2101</div><div>    frame #41: 0x91aece90 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2859</div><div>    frame #42: 0x91aec35d AppKit`-[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 134</div><div>    frame #43: 0x9136fa7d AppKit`-[NSApplication run] + 763</div><div>    frame #44: 0x91341b3a AppKit`NSApplicationMain + 1228</div><div>    frame #45: 0x0016558b Squeak`main(argc=2, argv=0xbffff624, envp=0xbffff630) + 91 at main.m:52</div><div>    frame #46: 0xa728f611 libdyld.dylib`start + 1</div></div><div><br></div><div><br></div><div>I changed sqSqueakOSXApplication.m in August, but only to add some option processing.  Anyone have any ideas?</div><div><br></div><div>-- <div dir="ltr" class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840m_-2820751487162381083gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_6180066402562276951gmail-m_-3319198124909489828m_-3471242150214172840gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_6180066402562276951gmail-m_-3319198124909489828gmail_signature"><div dir="ltr"><div><div dir="ltr">===========================================================================<br>John M. McIntosh. Corporate Smalltalk Consulting Ltd <a href="https://www.linkedin.com/in/smalltalk" target="_blank">https://www.linkedin.com/in/smalltalk</a><br>===========================================================================<br></div></div></div></div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_6180066402562276951gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>