<div dir="ltr"><div>There is also the Project>>primitiveError: if the UI process get in trouble</div><div><br></div><div>Best,</div><div>Karl<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 2, 2022 at 11:13 PM Jaromir Matas <<a href="mailto:mail@jaromir.net">mail@jaromir.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div style="overflow-wrap: break-word;" lang="EN-US">
<div class="gmail-m_7712001060282871413WordSection1">
<p class="MsoNormal">Hi Eliot, Marcel, all</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">> This sounds right to me.  The important things would be <u></u><u></u></p>
<p class="MsoNormal">- is the activeProcess (in which the exception occurs) the UI process?  If so don’t create a new UI process.<u></u><u></u></p>
<p class="MsoNormal">- is the UI process blocked temporarily or long-term?  I’m guessing there are delays in the UI process’s stepping/rendering so some simple test for blocking might assume the UI process was blocked while in fact it was just pausing.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Yes, I realize the UI may be in a blocked state most of the time because of the intercycle pause which is not the case we need to isolate; so yes, we need some more clever test than simple #isBlocked.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Another thing is that the blocked UI will/may eventually (when signaled) become active again so if we create a new UI to deal with a subsequent error (i.e. a request to open a debugger) then this new UI should really be just “temporary”
 and should be closed when the original UI becomes active again; and this is at the moment way beyond my skills; I’m not even sure this is the right approach :)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">> But I really *don’t* know what I’m talking about here.  I would talk it over with Marcel; he’s much more familiar with the code and co-located.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">That would be a great help indeed :))<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Can I assume we can agree that it would be nice and reasonable if this motivation example opened the ZeroDivide without freezing the UI ?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">s := Semaphore new.<u></u><u></u></p>
<p class="MsoNormal">[1/0. s signal] fork.<u></u><u></u></p>
<p class="MsoNormal">s wait<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks!</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><span lang="CS">--</span></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><strong><span style="font-family:"Calibri Light",sans-serif;color:rgb(51,51,51);font-weight:normal">Jaromír Matas</span></strong><span style="font-family:"Calibri Light",sans-serif;color:rgb(85,85,85)"><u></u><u></u></span></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><span style="font-family:"Calibri Light",sans-serif;color:rgb(46,117,182)"><a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal" style="border:medium none;padding:0in"><b>From: </b><a href="mailto:eliot.miranda@gmail.com" target="_blank">Eliot Miranda</a><br>
<b>Sent: </b>Saturday, July 2, 2022 19:23<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">The general-purpose Squeak developers list</a><br>
<b>Subject: </b>Re: [squeak-dev] Freezing UI issue</p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi Jaromir,<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
<br>
<u></u><u></u></p>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<p class="MsoNormal" style="margin-bottom:12pt">On Jul 1, 2022, at 2:43 AM, Jaromir Matas <<a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a>> wrote:<u></u><u></u></p>
</blockquote>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Hi All,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I'd like to ask you to help me understand this: If you run the following example in the Workspace, the UI will freeze (Alt + . recoverable indeed)<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">s := Semaphore new.<u></u><u></u></p>
<p class="MsoNormal">[1/0. s signal] fork.<u></u><u></u></p>
<p class="MsoNormal">s wait<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">The reason is obvious - the example runs inside the UI and hence the UI will start waiting on the semaphore s. At the same time the newly forked process will try to evaluate 1/0 and will request the UI to open a debugger but this won't
 happen because the UI is waiting on a semaphore.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Now the question: Why the system won't start the debugger in a new UI? There's no 'fundamental' reason why the UI should get stuck on a semaphore instead of taking care of the new error that occurred elsewhere in the meantime. Look at 
 #spawnNewProcessIfThisIsUI: : the method tries to make sure there's a running UI so that a new debugger can be opened in case the UI is missing or is suspended. It feels like the situation where the UI *is blocked* has been left off - and I can't figure out
 whether by omission or intentionally.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I've tried to modify it like this:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">spawnNewProcessIfThisIsUI: suspendedProcess<u></u><u></u></p>
<p class="MsoNormal">                "Initialize a UI process if needed. Answer true if suspendedProcess was interrupted<u></u><u></u></p>
<p class="MsoNormal">                from a UI process."<u></u><u></u></p>
<p class="MsoNormal">                self uiProcess == suspendedProcess ifTrue: [<u></u><u></u></p>
<p class="MsoNormal">                                self spawnNewProcess.<u></u><u></u></p>
<p class="MsoNormal">                                ^true<u></u><u></u></p>
<p class="MsoNormal">                ].<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">                "Ensure that the UI process is running."<u></u><u></u></p>
<p class="MsoNormal">                self uiProcess<u></u><u></u></p>
<p class="MsoNormal">                                ifNil: [self spawnNewProcess]<u></u><u></u></p>
<p class="MsoNormal">                                ifNotNil: [:p | (p isSuspended or: [p isBlocked]) ifTrue: [     "<------- here's my change... or: [p isBlocked]"<u></u><u></u></p>
<p class="MsoNormal">                                                self restoreDisplay.<u></u><u></u></p>
<p class="MsoNormal">                                                self uiProcess resume]].<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">                ^false                    "no new process was created"<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">... and the example above no longer blocks the UI !<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I'm not saying this is a fix (I don't have any debugger/UI experience to fix it correctly); I'm just trying to demonstrate the functionality I'd like to achieve :) A real fix should maybe open a new UI instead of unblocking the existing
 one, I don't know…<u></u><u></u></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">This sounds right to me.  The important things would be <u></u><u></u></p>
<div>
<p class="MsoNormal">- is the activeProcess (in which the exception occurs) the UI process?  If so don’t create a new UI process.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">- is the UI process blocked temporarily or long-term?  I’m guessing there are delays in the UI process’s stepping/rendering so some simple test for blocking might assume the UI process was blocked while in fact it was just pausing.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">But I really *don’t* know what I’m talking about here.  I would talk it over with Marcel; he’s much more familiar with the code and co-located.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <br>
<br>
<u></u><u></u></p>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thanks very much for any input on this.<u></u><u></u></p>
<p class="MsoNormal">best,<u></u><u></u></p>
<p class="MsoNormal">Jaromir<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><span lang="CS">--</span></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><strong><span style="font-family:"Calibri Light",sans-serif;color:rgb(51,51,51);font-weight:normal">Jaromír Matas</span></strong></p>
<p class="gmail-m_7712001060282871413MsoNoSpacing"><span style="font-family:"Calibri Light",sans-serif;color:rgb(46,117,182)"><a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a></span></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="margin-right:0.5in;margin-bottom:5pt;margin-left:0.5in">
<u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

<br>
</blockquote></div>