[Cuis-dev] Bug fix: Image freezes when inspecting objects with huge #printOn: results

Andres Valloud ten at smallinteger.com
Tue Oct 31 16:09:41 PDT 2023


Yeah, sometimes trying to be helpful (sorting the keys) ends up being 
too helpful.

But let's say something equivalent to this turned up again later.  Does 
this mean that any operation related to the GUI that does not finish 
quickly enough will hang the image?

On 10/31/23 2:53 PM, Juan Vuletich wrote:
> Hi Andrés,
> 
> On 10/31/2023 12:51 AM, Andres Valloud via Cuis-dev wrote:
>> Generally, no tools should cause too much demands on the running 
>> system, because you never know if the user will need the tools to 
>> diagnose a low resource situation.  Object>>printStringLimitedTo:?
> 
> Yes. Precisely. That's what is being used here. The problem was that 
> calling #printStringLimitedTo: on a Dictionary involved sorting the keys 
> before the streaming starts. This could mean an unbounded amount of 
> time, even if the actual number of keys actually printed could be really 
> small!
> 
> So, the solution is simply _not_ to sort the keys.
> 
> Thanks,
> 
>>
>> On 10/30/23 2:40 PM, Juan Vuletich via Cuis-dev wrote:
>>> On 10/29/2023 6:28 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
>>>> Hi folks,
>>>>
>>>> The attached changeset fixes a bug that caused the image to freeze 
>>>> when inspecting objects with huge #printOn: results.
>>>>
>>>> To reproduce the error:
>>>>
>>>>  1. Open a workspace
>>>>  2. Evaluate CompiledMethod allInstances inject: Dictionary new into:
>>>>     [ :dict :method |  dict at: method put: method sourceCode. dict ]
>>>>  3. An inspector will be opened on the dictionary created above Click
>>>>     on self
>>>>  4. Notice the image hangs while waiting for the #printOn: message 
>>>> send.
>>>>
>>>> To fix this bug, I limited the time to print the selected item to 
>>>> 300 milliseconds and showed an appropriate error message when that 
>>>> happened.
>>>>
>>>> LMK your thoughts.
>>>>
>>>> Cheers,
>>>> Nico PM
>>>
>>> Hi Nico,
>>>
>>> I think that using #valueWithin:onTimeout: is like shooting a 
>>> mosquito with a gun. I preferred a solution with two parts:
>>> - printing a Dictionary doesn't need to sort the keys. Dictionaries 
>>> are not sorted.
>>> - Any stepping morph that takes longer than its #stepTime will be 
>>> limited in its stepping time so GUI stays (barely) responsive.
>>>
>>> Updates now at GitHub.
>>>
>>> Thanks,
>>>
>>> -- 
>>> Juan Vuletich
>>> cuis.st
>>> github.com/jvuletich
>>> researchgate.net/profile/Juan-Vuletich
>>> independent.academia.edu/JuanVuletich
>>> patents.justia.com/inventor/juan-manuel-vuletich
>>> linkedin.com/in/juan-vuletich-75611b3
>>> twitter.com/JuanVuletich
>>>
>>>
> 
> 


More information about the Cuis-dev mailing list