UI.start_timer bug


I am having an issue with UI.start_timer that I do not understand at all. I am using timers to handle taking several screenshots, create some PDFs, and upload files to Box. This function has been working well for me for a long time now, however, I recently created a slightly modified copy of the function for a second tool where this function is called by another function (this seems to make a difference). Immediately after UI.start_timer ALL entities in the model are erased for no apparent reason. If I manually call this function it runs perfectly. Does anyone have any answers as to why this is happening?

I’ve never heard of anything like this. Do you have a code example that reproduces the problem?

We assume you are calling Sketchup::Model#export() to create the PDFs, and are on SketchUp 2016 or higher.

What platform are you seeing this issue on ? (Your profile says Windows 10.)

What are you using the timers for ? (I’m guessing to detect that the PDF files have been written and then copy them to a DropBox folder?)

Oh,… and whenever weird things like this happen, I suspect memory leak / corruption.
I close all apps, and reboot the computer, then see if the issue is repeatable.

You may also take a look at Outliner window to make sure, that all entities are actually erased. Sometimes entities are still in a model, but model view doesn’t display them after some certain actions performed by Ruby code.
Anyway I also haven’t yet encountered any problems with UI.start_timer so I assume that maybe something is going on in a slightly modified copy of the function you mentioned (not in UI.start_timer).

1 Like

I ended up resolving this. It was a confusion on my part. The Timer function was not what was deleting entities but was not working the way I expected it to. What was “erasing” all my entities was another function that resets SketchUp and opens a blank model that was supposed to run after the timers but was being run before/along-side the timers instead.

This sounds like you may have misunderstood the basic premise of the UI timers: they schedule a code block for later execution and then let other code continue to run while awaiting the scheduled time.

1 Like

ie, timer blocks are non synchronous (asynchronous.)

So as it is not a “bug”, … could you please edit the topic title and replace “bug” with “confusion” ?

… And you never answered …

… implying we might be able to suggest alternatives to timer blocks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.