Fusion 360 crashes when updating TextBoxCommandInput from another thread

Fusion 360 crashes when updating TextBoxCommandInput from another thread

Anonymous
Not applicable
408 Views
1 Reply
Message 1 of 2

Fusion 360 crashes when updating TextBoxCommandInput from another thread

Anonymous
Not applicable

I am running into an issue where Fusion 360 crashes (Completely, with Autodesk crash report popping up) when trying to update text from another thread

 

I am doing something in the background that takes a bit, so I am executing the action from another thread. I want to show the progress of the execution, so I have a text box where I display the percentage.

 

t = Thread(target=self.progressBarCallback, args=(progress,))
t.start()
 
This crashes Fusion. The callback is just a function that updates the input's formattedText:
self._input.formattedText = "<b align='center'>{}</b>".format(percent)
 
Not sure what causes this. Maybe it takes a long time to render the formatted text, and I'm updating too quickly, although slowing it down to once every second doesn't fix the issue either.
 
When I update a different CommandInput, like a BoolCommandInput's text, it doesn't crash and it updates perfectly fine from another thread and with hundreds of updates a second.
 
Is there some other way? I wanted to use the formattedText's html features to render a progress bar, but it doesn't seem like I can do that if it can't even handle text. Is there another way to put HTML snippets in?
0 Likes
409 Views
1 Reply
Reply (1)
Message 2 of 2

KrisKaplan
Autodesk
Autodesk

Hi,

 

All of the User Interface APIs are only supported to be called from the main/UI thread. (There really should be a check for this and a better error returned instead of allowing it to crash.)

 

You can still do processing on worker threads, but I would suggesting triggering a CustomEvent from your worker thread to trigger a CustomEventHandler on the main thread to update any UI elements.

 

Kris



Kris Kaplan
0 Likes