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

Webdlg debugging on Mac using WebKit inspector

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 7 Posters 1.3k Views 7 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
    slbaumgartner
    last edited by 25 Nov 2012, 15:37

    I don't know if this is common knowledge, but I didn't find a reference to it when searching sketchUcation, so I thought I'd share.

    If you turn on the WebKitDeveloperExtras for SketchUp on a Mac, you can get the "Inspect element" pane/window to analyze and debug webdlg pages! Here's how:

    Quit SketchUp

    First, find out the bundle id for your installation of SketchUp:

    • open a terminal window
    • type mdls /Applications/Google\ SketchUp\ 8/SketchUp.app | grep BundleIdentifier
      You should get a line like:
      kMDItemCFBundleIdentifier = "com.google.sketchupfree8"
      (obviously, this is from a free version install - the bundle id string will be different on pro)

    Next, enable the WebKitDeveloperExtras in SketchUp:

    • type defaults write com.google.sketchupfree8 "WebKitDeveloperExtras" -bool TRUE
      (use the bundle id string you got above)

    Now start SketchUp and open a tool that uses webdlg. If you right-click in the webdlg window, you will get a menu that says "Reload" and "Inspect Element". If you click the second choice, you will open the inspection pane/window (there is a setting on the inspector that chooses whether it opens as a pane in the target window or as a separate window). Now you can use the inspector to do things such as see which elements of the html and css affect what aspects of the display. You can also place breakpoints in javascript and single-step through the scripts to your heart's content. This technique eliminates the need to load your javascript up with alerts or similar debugging outputs, and can detect subtle errors that otherwise cause functions to abort silently.

    Enjoy,
    Steve

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 25 Nov 2012, 21:46

      I will have to try this! Struggling with some JS debugging under OSX.

      (Wonder if John (driven) told me this - but I never got around to try it.)

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

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by 25 Nov 2012, 23:16

        @unknownuser said:

        (Wonder if John (driven) told me this - but I never got around to try it.)

        Yes, Steve, you should have found it, maybe I used a different sting? ,but There is a ruby console version somewhere here.
        I'm in 'The Isle of Man' for next 3 days so can't check...
        Some jquery type dialogs need a gap created to get the options menu
        Adding a margin often works, or try a textarea

        Steve search my post to see some other mac tricks good and bad....
        John

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • S Offline
          slbaumgartner
          last edited by 27 Nov 2012, 21:00

          @driven said:

          @unknownuser said:

          (Wonder if John (driven) told me this - but I never got around to try it.)

          Yes, Steve, you should have found it, maybe I used a different sting? ,but There is a ruby console version somewhere here.
          I'm in 'The Isle of Man' for next 3 days so can't check...
          Some jquery type dialogs need a gap created to get the options menu
          Adding a margin often works, or try a textarea

          Steve search my post to see some other mac tricks good and bad....
          John

          It was hiding away, but eventually I did find your prior post. Seems I am destined to follow ignorantly in your footsteps a year behind!

          When analyzing the TestUp webdlg, I noticed a sort of catch-22: you can't open the WebKit inspector before loading the page, but that means you can't plant breakpoints in js that is executed as the page loads! The solution is to load the page, open the inspector, plant the breakpoints, and then use the right-click menu to reload the page. The breakpoints "stick" across the reload.

          regards,
          Steve

          1 Reply Last reply Reply Quote 0
          • A Offline
            archidave
            last edited by 23 Jul 2014, 16:17

            Does anyone know how to enable something like this on a Windows machine? The WebKit inspector on Mac is brilliant for debugging webdialogs, but I need to debug a problem that seems to be occurring on Windows only.
            Is there a way to enable Firebug within the SketchUp webdialogs or some kind of native DOM inspector for IE?

            thanks
            Dave

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 23 Jul 2014, 20:11

              I have enabled the development edition of FireBug, in the past, ... but it's been so long I don't remember how.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • A Offline
                Aerilius
                last edited by 24 Jul 2014, 11:36

                Found in the lost manual: https://github.com/thomthom/sketchup-webdialogs-the-lost-manual/wiki/Debugging

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tt_su
                  last edited by 24 Jul 2014, 11:48

                  Install Visual Studio Express (free). Then you can either attach it to SketchUp's process, or inject debugger; statement in your JS code to make the system prompt you to debug. You can then set breakpoints in Visual Studio and inspect variables and call stacks.

                  I sometimes use a catch-all code like this to trigger the debugger on errors without having to inject debugger; around in the code:

                  
                  window.onerror = function(message, location, linenumber, error)
                  {
                    // Trigger an request to attach debugger.
                    debugger;
                    return false;
                  };
                  
                  
                  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