sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    A way to avoid that ?

    Scheduled Pinned Locked Moved Developers' Forum
    29 Posts 6 Posters 11.6k Views 6 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      @thomthom said:

      Yes - as long as the operations a kept small it'll prevent whiteout.

      "whiteout" = "ghost window"

      @unknownuser said:

      (http://msdn.microsoft.com/en-us/library/ms644943(v)":2x9onnad]If a top-level window stops responding to messages for more than several seconds, the system considers the window to be not responding and replaces it with a ghost window that has the same z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even close the application. However, these are the only actions available because the application is actually not responding. When an application is being debugged, the system does not generate a ghost window.

      When Sketchup goes into "ghost mode", you will see it listed as "Skethcup (not responding)" in the Task Manager.

      First of all, changing the interval that Windows uses to determine when a process is "not responding", although possible, causes other major headaches systemwide. Also, I think that it requires a registry change and reboot (if memory serves me,) so is not a serious option for us.

      I would attempt to force a [PeekMessage](http://msdn.microsoft.com/en-us/library/ms644943(v) system call, for Sketchup's thread, within the "responding inteval" (can't remember offhand what it is.)

      So any way it's not your add entities block that needs to go inside a UI.start_timer proc, ... it's a API call to PeekMessage, like:

      begin
        peek = UI.start_timer(interval, true) {
         peek_window_msg()
        }
        do_create_lots_of_model_entities()
        UI.stop_timer(peek)
      end
      

      where, peek_window_msg() would be a method that sets up and makes the proper API call. (It should NOT delete any messages from the queue, basically it is just acknowledging to the system that Sketchup knows that messages are pending to be processed.)

      It would be better (for us,) if something like this was built into the main() loop (prodived C++ has something like a start_timer function.) Perhaps John Hauswirth might know if it's possible.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        The other option, would be to "fool" the system into thinking that Sketchup was being debugged, during the long add entities block.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Have you used that PeekMessage thing?

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            That would be awesome if it works. πŸ‘

            Hi

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @dan rathbun said:

              A debugger object needs to be created and attached to the Sketchup process, etc.

              I am wary of releasing anything that does something this drastic.. and because BugSplat! is also likely a (post-mortem) debugger implementation... the last thing I want to do is break the BugSplat! functionality.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @thomthom said:

                Have you used that PeekMessage thing?

                I haven't had time yet myself, (as I have not yet written any code that creates a long Ruby processing delay.)

                Also.. it has been a few months since I read that MSDN page, and just noticed the last item about debug mode. (A quick look into this, seems much more complex. A debugger object needs to be created and attached to the Sketchup process, etc.)

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Haaaaaaah!!!!!

                  Just made a really quick and dirty hack - calling PeekMessage at the inner most loop:

                  <span class="syntaxdefault"><br />&nbsp;&nbsp;PeekMessage&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Win32</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">API</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">'PeekMessage'&nbsp;</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'PLIII'</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'I'</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'user32'</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span class="syntaxdefault">def&nbsp;self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">refresh<br />&nbsp;&nbsp;&nbsp;&nbsp;msg&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">'&nbsp;'&nbsp;</span><span class="syntaxkeyword">*&nbsp;</span><span class="syntaxdefault">2048<br />&nbsp;&nbsp;&nbsp;&nbsp;r&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">PeekMessage</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">call</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">msg</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /></span>
                  

                  worked perfectly!!!!

                  Though I think one might want to time the peek after a given short enough time. (And msg needs to be of correct size...)

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    tried using a timer to sending PeekMessage - while the inner loop did its thing.
                    didn't work. the inner loop blocked it. So the inner loops need to call this. which means that when SU's methods are processing they will probably block the UI . like intersecting many entities.

                    But in many cases this can really help.

                    of course - OSX users are out of luck....

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      Oh, that's interesting.

                      Couple a thoughts - terminate the message with a c language null: '\0' (just in case?) The size should still be 2048 including the null.

                      More obviously, you don't need to peek every loop iteration - so something like:

                      refresh if (loop_counter % 500 == 0)

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @jim said:

                        Couple a thoughts - terminate the message with a c language null: '\0' (just in case?)

                        Isn't that just for strings?
                        The string I pass is just a data buffer that will be filled with binary data - which one has to extract.

                        @jim said:

                        More obviously, you don't need to peek every loop iteration - so something like:
                        refresh if (loop_counter % 500 == 0)

                        Yes - more pragmatic than calculating time. I like it, it's KISS.

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          Jim
                          last edited by

                          @thomthom said:

                          Isn't that just for strings?

                          Yeah, I made an assumption the message was a c character array.

                          Hi

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            @jim said:

                            @thomthom said:

                            Isn't that just for strings?

                            Yeah, I made an assumption the message was a c character array.

                            No, it's a MSG structure. Just didn't bother to work out exactly how large it is. (probably will be making a wrapper for this.) So I just make a large buffer while I quickly tested it.
                            ...if I don't need the returned message, would it be ok to just send an empty buffer?

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              @dan rathbun said:

                              @thomthom said:

                              Yes - as long as the operations a kept small it'll prevent whiteout.

                              "whiteout" = "ghost window"

                              ...[snip]...

                              I would attempt to force a [PeekMessage](http://msdn.microsoft.com/en-us/library/ms644943(v) system call, for Sketchup's thread, within the "responding inteval" (can't remember offhand what it is.)

                              So any way it's not your add entities block that needs to go inside a UI.start_timer proc, ... it's a API call to PeekMessage, like:

                              begin
                              >   peek = UI.start_timer(interval, true) {
                              >    peek_window_msg()
                              >   }
                              >   do_create_lots_of_model_entities()
                              >   UI.stop_timer(peek)
                              > end
                              

                              where, peek_window_msg() would be a method that sets up and makes the proper API call.

                              @ThomThom & friends, ... I stumbled across where I saw the 'whiteout' interval.
                              It's specified on the [IsHungAppWindow](http://msdn.microsoft.com/en-us/library/ms633526(v) Function reference page.
                              Says 5 seconds.

                              So perhaps:

                              begin
                                interval =( Sketchup.version.to_i<8 ? 4 ; 4.9 )
                                peek = UI.start_timer(interval, true) {
                                 peek_window_msg()
                                }
                                do_create_lots_of_model_entities()
                                UI.stop_timer(peek)
                              end
                              

                              I'm not here much anymore.

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                Interesting - from that article.

                                @unknownuser said:

                                An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds.

                                Though, it seems one can't reply on that time.

                                @unknownuser said:

                                The Windows timeout criteria of 5 seconds is subject to change.

                                I have set the interval to a handful of times per second because I use it to force SU to update its statusbar.

                                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • Dan RathbunD Offline
                                  Dan Rathbun
                                  last edited by

                                  I still wonder if a peek message loop could be written into the commit_operation API method.

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • Dan RathbunD Offline
                                    Dan Rathbun
                                    last edited by

                                    And there is another 'nutty' thing that happens. When the ghost window is created, it has a different handle then the "real" application window. There are a couple functions that return the other handle, depending on which window handle you grab. (Strange that the IsHungAppWindow function is "not for general use.")

                                    I'm not here much anymore.

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      @dan rathbun said:

                                      I still wonder if a peek message loop could be written into the commit_operation API method.

                                      I made a wrapper iterator that will take an enumerator objects and wrap it in between start and commit operation while updating the progress in the statusbar, kept alive by PeekMessage limited to a certain interval. Works really well for simple one-iteration operations.

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • nikusknxN Offline
                                        nikusknx
                                        last edited by

                                        Update for Sketchup 2014 :

                                        
                                        require "Win32API.rb
                                        msg = "\000" * 36
                                        peekMessage = Win32API.new('user32','PeekMessage' , 'PLIII', 'I')
                                        peekMessage.call( msg, 0, 0, 0, 0x0000 ) != 0
                                        
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • 1
                                        • 2
                                        • 1 / 2
                                        • First post
                                          Last post
                                        Buy SketchPlus
                                        Buy SUbD
                                        Buy WrapR
                                        Buy eBook
                                        Buy Modelur
                                        Buy Vertex Tools
                                        Buy SketchCuisine
                                        Buy FormFonts

                                        Advertisement