<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><br></div><div><br></div><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="color:rgb(79,129,135);font-family:Menlo;font-size:13px"> </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></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:0 0 0 .8ex;border-left:1px #ccc solid;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`-[<wbr>sqSqueakOSXApplication setupSoundLogic](self=<wbr>0x02408810, _cmd="setupSoundLogic") + 412 at sqSqueakOSXApplication.m:152</div><div>   149 <span class="m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">               </span>snd_Start(2644, 22050, 1, 0);</div><div>   150 <span class="m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">              </span>char silence[10576];</div><div>   151 <span class="m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">               </span>bzero(&silence, sizeof(silence));</div><div>-> 152 <span class="m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">             </span>snd_PlaySamplesFromAtLength(<wbr>2644,(usqInt * ) &silence,0);</div><div>   153 <span class="m_-3471242150214172840gmail-Apple-tab-span" style="white-space:pre-wrap">           </span>[self.soundInterfaceLogic snd_Stop_Force];</div><div>   154 <span class="m_-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:0 0 0 .8ex;border-left:1px #ccc solid;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_<wbr>ShellSimpleProxyList::<wbr>Reconcile(bool, bool) + 646</div><div>    frame #8: 0x9331f569 CoreAudio`HALC_ShellPlugIn::<wbr>ConnectToServer() + 153</div><div>    frame #9: 0x9338904e CoreAudio`HAL_HardwarePlugIn_<wbr>InitializeWithObjectID(<wbr>AudioHardwarePlugInInterface**<wbr>, unsigned long) + 78</div><div>    frame #10: 0x9331d818 CoreAudio`HALPlugIn::<wbr>Initialize() + 48</div><div>    frame #11: 0x9331c3a0 CoreAudio`HALPlugInManagement:<wbr>:CreateHALPlugIn(HALCFPlugIn const*) + 2048</div><div>    frame #12: 0x9331ac08 CoreAudio`HALPlugInManagement:<wbr>:Initialize() + 552</div><div>    frame #13: 0x93317070 CoreAudio`HALSystem::<wbr>CheckOutInstance() + 190</div><div>    frame #14: 0x9331e4bb CoreAudio`<wbr>AudioObjectGetPropertyData + 81</div><div>    frame #15: 0x92643947 AudioToolbox`AQMEIO_HAL::Init(<wbr>) + 201</div><div>    frame #16: 0x92643132 AudioToolbox`AQMEIOManager::_<wbr>FindIOUnit(__CFString const*) + 110</div><div>    frame #17: 0x92642f23 AudioToolbox`AQMEDevice::<wbr>InitPhase2(__CFString const*) + 239</div><div>    frame #18: 0x92642e2e AudioToolbox`AQMixEngine_<wbr>Single::InitPhase2() + 24</div><div>    frame #19: 0x92642a34 AudioToolbox`AQIONodeManager::<wbr>_FindAQIONode(bool, __CFString const*) + 154</div><div>    frame #20: 0x926426a9 AudioToolbox`AudioQueueObject:<wbr>:DoIONodeConnect(bool) + 963</div><div>    frame #21: 0x92715bfe AudioToolbox`AudioQueueObject:<wbr>:GetIONodeConnection_Init(<wbr>long&) + 40</div><div>    frame #22: 0x9270b7c6 AudioToolbox`AudioQueueObject:<wbr>:GetConverterConnection_Init(<wbr>long&) + 20</div><div>    frame #23: 0x9265a77b AudioToolbox`AudioQueueObject:<wbr>:AcquirePlayResources() + 215</div><div>    frame #24: 0x92709095 AudioToolbox`AudioQueueObject:<wbr>: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`-[<wbr>sqSqueakSoundCoreAudio snd_PlaySamplesFromAtLength:<wbr>arrayIndex:startIndex:](self=<wbr>0x0262e990, _cmd="snd_<wbr>PlaySamplesFromAtLength:<wbr>arrayIndex:startIndex:", frameCount=2644, arrayIndex="", startIndex=0) + 481 at sqSqueakSoundCoreAudio.m:319</div><div>    frame #28: 0x0021ed8d Squeak`snd_<wbr>PlaySamplesFromAtLength(<wbr>frameCount=2644, arrayIndex=0xbfffb588, startIndex=0) + 125 at sqSqueakSoundCoreAudioAPI.m:62</div><div>    frame #29: 0x0015358c Squeak`-[<wbr>sqSqueakOSXApplication setupSoundLogic](self=<wbr>0x02408810, _cmd="setupSoundLogic") + 412 at sqSqueakOSXApplication.m:152</div><div>    frame #30: 0x0016b5c9 Squeak`-[<wbr>sqSqueakMainApplication runSqueak](self=0x02408810, _cmd="runSqueak") + 617 at sqSqueakMainApplication.m:198</div><div>    frame #31: 0x95216299 Foundation`__<wbr>NSFirePerformWithOrder + 432</div><div>    frame #32: 0x9379a496 CoreFoundation`__CFRUNLOOP_IS_<wbr>CALLING_OUT_TO_AN_OBSERVER_<wbr>CALLBACK_FUNCTION__ + 22</div><div>    frame #33: 0x9379a3b2 CoreFoundation`__<wbr>CFRunLoopDoObservers + 498</div><div>    frame #34: 0x9377d7fd CoreFoundation`__CFRunLoopRun + 1661</div><div>    frame #35: 0x9377ce51 CoreFoundation`<wbr>CFRunLoopRunSpecific + 641</div><div>    frame #36: 0x9377cbba CoreFoundation`<wbr>CFRunLoopRunInMode + 122</div><div>    frame #37: 0x92d7a37b HIToolbox`<wbr>RunCurrentEventLoopInMode + 321</div><div>    frame #38: 0x92d79f5f HIToolbox`<wbr>ReceiveNextEventCommon + 454</div><div>    frame #39: 0x92d79d7b HIToolbox`_<wbr>BlockUntilNextEventMatchingLis<wbr>tInModeWithFilter + 71</div><div>    frame #40: 0x9137ab2d AppKit`_DPSNextEvent + 2101</div><div>    frame #41: 0x91aece90 AppKit`-[NSApplication(<wbr>NSEvent) _nextEventMatchingEventMask:<wbr>untilDate:inMode:dequeue:] + 2859</div><div>    frame #42: 0x91aec35d AppKit`-[NSApplication(<wbr>NSEvent) nextEventMatchingMask:<wbr>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 <wbr>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_-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_-3471242150214172840gmail_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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_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>