7 posts • Page 1 of 1
I'm seeing a strange issue with a plugin I built in OS X. The first time it's run after loading SketchUp it will occasionally beachball. Not every time, and there's no special action taken on the first run that would explain its behavior. If it runs successfully the first time, it will run without problem again in the same session. Has anyone seen a similar problem? Where would you start to debug it?
How about more info ??
What kind of a plugin is it ??
Did you properly module wrap it in a unique namespace ??
Does it use any Observers?
If so.. any of those with problems as ThomThom has graphed here?
Do you have the console open when you load it?
Are any exception messages output ??
Does it use a WebDialog ?
If so does it open one immediately upon loading ?
Does it use any platform specific interfaces, like AppleScript, etc ?
Hi Dan. Thanks for the reply.
The plugin's fairly straight forward. Essentially it's traversing the model and counting components and material usage.
Good catch on the namespace issue. I'd overlooked that. I'll add it immediately.
No observers or platform specific interfaces.
It does open a WebDialog on load. I didn't realize that could be an issue. Very curious to hear more. Is there anything I can read about it?
You should not really need to "traverse" the model entities.
Each component definition keeps a list of all it's instances, no matter what their nesting level.
ADD: By iterating the Sketchup::DefinitionList collection object, for the model,... you skip having to ignore entity types, that you do not need to test, ie Edges, etc. And your iteration should be much faster. (I suspect the random beach-balling occurs with larger models, or those that may return entity types during the iteration that you did not expect, and your code may not handle well. ie Images, EdgeLoop, etc.)
Also.. as each Sketchup::ComponentInstance object shares it's definition's entities with all it's sibling instances (ie, the instance does not have unique drawing elements of it's own,) ... each used component's entities collection need only be iterated ONCE, to see if there are any "hardset" materials assigned to faces, etc. (Those with default material == nil will get the material assigned to the instance itself.)
So access to a definition entities collection, is quickest via the model's Sketchup::DefinitionList.
ADD #2: Do not use obj.typename == "Typestring" as it is very slow.. instead, use obj.is_a?(Sketchup::ClassName)
Last edited by Dan Rathbun on Wed Mar 28, 2012 11:38 pm, edited 2 times in total.
Check the [ Code Snippets ] Index thread.
Which has Topical Sub indexes...
[Info] Platform Issues / Differences / Specifics
.. and see it's WebDialog section(s), under each platform (or concentrate on the Mac issues.)
Stuart.. have you updated to v8M3, and if so do you still see this slowness on loading ?
Mac "beachballs" differently regardless of your plugin.
I have a lot of plugins and the time to load is "variable". Sometimes it beachballs for a while, sometimes not.
It's almost like there is a cache somewhere, that is emptied after a while. It seems the first time I load SU in a while it takes more time, then it goes faster. Not as clear cut but kind of.
So the correlation may not be with YOUR plugin.
That said however, careful for loose ends as that will greatly lengthened the beachballing in general (make the short one long and the long one longer)
7 posts • Page 1 of 1