• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Plugin beachballs seemingly randomly on first load

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 3 Posters 286 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    stuarth
    last edited by 9 Mar 2012, 22:02

    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?

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 23 Mar 2012, 03:04

      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 ?

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • S Offline
        stuarth
        last edited by 28 Mar 2012, 19:45

        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 ?

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 28 Mar 2012, 21:43

          @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's WebDialog section(s), under each platform (or concentrate on the Mac issues.)

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 28 Mar 2012, 22:38

            @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)

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 31 May 2012, 04:05

              Stuart.. have you updated to v8M3, and if so do you still see this slowness on loading ?

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • M Offline
                Michaelv
                last edited by 2 Jun 2012, 17:50

                @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)

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement