Plugin beachballs seemingly randomly on first load
-
Hi
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?
@dan rathbun said:
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 ?
-
@stuarth said:
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?
Check the [ Code Snippets ] Index thread.
Which has Topical Sub indexes...
[Info] Platform Issues / Differences / Specifics
.. and see it'sWebDialog
section(s), under each platform (or concentrate on the Mac issues.) -
@stuarth said:
The plugin's fairly straight forward. Essentially it's traversing the model and counting components and material usage.
You should not really need to "traverse" the model entities.
numc = 0 numi = 0 matls = 0 model.definitions.each {|cdef| if cdef.instances.size > 0 numc += 1 numi += cdef.instances.size cdef.instances.each {|i| matls += 1 unless i.material.nil? } end }
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)
-
Stuart.. have you updated to v8M3, and if so do you still see this slowness on loading ?
-
@stuarth said:
Hi
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?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)
Advertisement