sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    Between different Macs plugin works and doesn't work

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    48 貼文 6 Posters 2.3k 瀏覽 6 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • G 離線
      Garry K
      最後由 編輯

      I'm not sure that there is an http error. A value of 0 suggests that the call did not go beyond the computer. This suggests that it is possible that it has something to do with cross-domain requests. However, Sketchup does have the allow_actions_from_host which was set. I thought allow_actions_from_host was specifically for that, in otherwords to reduce security risks by allowing 1 and 1 only external call.

      What we could do is rem out the "loaded" part where we add the listener for DOMContentLoaded and replace that with a button and push the data to a hidden field.

      Then there is but one call back going in one direction. Now if that doesn't work then we have ruled out this being an asynchronous timing thing.

      Any thoughts?

      1 條回覆 最後回覆 回覆 引用 0
      • S 離線
        slbaumgartner
        最後由 編輯

        @garry k said:

        I'm not sure that there is an http error. A value of 0 suggests that the call did not go beyond the computer. This suggests that it is possible that it has something to do with cross-domain requests. However, Sketchup does have the allow_actions_from_host which was set. I thought allow_actions_from_host was specifically for that, in otherwords to reduce security risks by allowing 1 and 1 only external call.

        What we could do is rem out the "loaded" part where we add the listener for DOMContentLoaded and replace that with a button and push the data to a hidden field.

        Then there is but one call back going in one direction. Now if that doesn't work then we have ruled out this being an asynchronous timing thing.

        Any thoughts?

        Rambling thoughts...

        I've become convinced that it is not an async timing problem. I also don't think it is an http error per-se, since those report three-digit codes (your javascript labels it an "http error", not the system). I suspect the request is being killed within the javascript library without ever going to the server. Have you checked the server logs to see whether they get traffic when Walt's system logs the error? My guess is no.

        I didn't find any discussion about ways for client-side code to turn off the blocking of cross-domain requests,
        only server-side headers that could be returned. It seems unlikely that there is a way for client code to disable the action, since that would make it essentially useless! What good is having a lock on the door if you provide a turn button to disengage it? So, I'd be surprised if SU's allow_actions_from_host defeats this particular security feature (or if it does, I'd like to know how - this is another of the poorly explained features of the API).

        From what I read, at least on many web libraries, XMLHttpRequest has an onerror event handler you can set that may provide a description of what went wrong. Something like

        
        xmlHttpRequest.onerror = function(e) {alert("request error; " + e.status.text)};
        
        

        It may be that the error message also shows up on a javascript console, if people with the problem can get one open before running the plugin.

        Steve

        1 條回覆 最後回覆 回覆 引用 0
        • S 離線
          slbaumgartner
          最後由 編輯

          More thoughts: I don't think it is allow_actions_from_host. From what I looked up, that setting controls whether skp: callbacks are allowed from WebDialog contents loaded from a remote host. It is a sort of whitelist that gates whether skp: will work (and actually did nothing on OS X prior to Mavericks!). But clearly you are getting callbacks from javascript to Ruby ok. I still think it is most likely a change in handling of the AJAX cross-domain security in Lion vs later OS X. And I have no clue how to work around it 😞

          1 條回覆 最後回覆 回覆 引用 0
          • TIGT 線上
            TIG Moderator
            最後由 編輯

            If a webdialog is not connecting to a server across the Internet you should never need to specify dlg.allow_actions_from_host(host) at all...
            If you do need to use it, then make sure that its argument is a 'domain' - like 'sketchucation.com' - and not an 'http-address' - like 'http://sketchucation.com'.
            On PCs and non-Mavericks MACs this difference was not a critical matter, but mis-setting it will surely break your webdialogs under the stricter Safari shipped with the new Mavericks.
            So it's best to ensure that a valid 'domain' is used...

            TIG

            1 條回覆 最後回覆 回覆 引用 0
            • S 離線
              slbaumgartner
              最後由 編輯

              Garry,

              You might want to try out some of the CORS methods described in this article:

              Link Preview Image
              Cross-Origin Resource Sharing (CORS) - HTTP | MDN

              Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in order to check that the server will permit the actual request. In that preflight, the browser sends headers that indicate the HTTP method and headers that will be used in the actual request.

              favicon

              MDN Web Docs (developer.mozilla.org)

              1 條回覆 最後回覆 回覆 引用 0
              • G 離線
                Garry K
                最後由 編輯

                Jeff and Walt

                I changed this based on what TIG said.

                Please try it


                modified dialog_test.rb

                1 條回覆 最後回覆 回覆 引用 0
                • M 離線
                  mwm5053
                  最後由 編輯

                  This is what I get Garry


                  Screen Shot 2014-02-15 at 1.46.02 PM.png

                  2011 iMac
                  SU 2015 Pro, 2017 Make
                  V2 Twilight
                  macOS Sierra 10.12.5

                  1 條回覆 最後回覆 回覆 引用 0
                  • G 離線
                    Garry K
                    最後由 編輯

                    Just to be sure - you downloaded the latest dialog_test.rb and line 10 now says:
                    @dlg.allow_actions_from_host( 'cabmaker32.com/' );

                    1 條回覆 最後回覆 回覆 引用 0
                    • M 離線
                      mwm5053
                      最後由 編輯

                      Yes Garry I deleted the other one and installed the the new one.


                      Screen Shot 2014-02-15 at 2.15.53 PM.png

                      2011 iMac
                      SU 2015 Pro, 2017 Make
                      V2 Twilight
                      macOS Sierra 10.12.5

                      1 條回覆 最後回覆 回覆 引用 0
                      • S 離線
                        slbaumgartner
                        最後由 編輯

                        @garry k said:

                        Just to be sure - you downloaded the latest dialog_test.rb and line 10 now says:
                        @dlg.allow_actions_from_host( 'cabmaker32.com/' );

                        Trailing slash not needed. Just 'cabmaker32.com'

                        1 條回覆 最後回覆 回覆 引用 0
                        • TIGT 線上
                          TIG Moderator
                          最後由 編輯

                          Remove the final / in the domain name. 😕

                          TIG

                          1 條回覆 最後回覆 回覆 引用 0
                          • G 離線
                            Garry K
                            最後由 編輯

                            Jeff and Walt

                            I have now removed the trailing slash from cabmaker32.com on line 10

                            Maybe this will work.
                            Please try it


                            cleaned up the domain address

                            1 條回覆 最後回覆 回覆 引用 0
                            • M 離線
                              mwm5053
                              最後由 編輯

                              Got the same error, sorry wish I could be of more help

                              2011 iMac
                              SU 2015 Pro, 2017 Make
                              V2 Twilight
                              macOS Sierra 10.12.5

                              1 條回覆 最後回覆 回覆 引用 0
                              • S 離線
                                slbaumgartner
                                最後由 編輯

                                @mwm5053 said:

                                Got the same error, sorry wish I could be of more help

                                Walt,

                                Do you have the WebKit inspector activated? If not, please open a Terminal window and type

                                defaults write <bundleid> WebKitDeveloperExtras -bool true

                                where you replace <bundleid> with:
                                com.google.sketchupfree8 for v8 Free
                                com.google.sketchuppro8 for v8 Pro (what your info says you have)
                                com.sketchup.SketchUp for 2013

                                After doing that, please run Garry's test script and while the WebDialog labeled "connect to website" is still open, right-click on it and select "Inspect Element" from the popup menu. This will open the WebKit Inspector. The GUI of the WebKit Inspector has changed with version, but look for something labeled "Console" and click it. Please let us know if the Console displays any error or warning messages.

                                Thanks
                                Steve

                                1 條回覆 最後回覆 回覆 引用 0
                                • M 離線
                                  mwm5053
                                  最後由 編輯

                                  @ Steve When I right click in Connect to Website all I get is "Reload" but this is what Terminal looks like after pressing return in terminal was that right?


                                  Screen Shot 2014-02-16 at 7.45.45 PM.png

                                  2011 iMac
                                  SU 2015 Pro, 2017 Make
                                  V2 Twilight
                                  macOS Sierra 10.12.5

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • S 離線
                                    slbaumgartner
                                    最後由 編輯

                                    @mwm5053 said:

                                    @ Steve When I right click in Connect to Website all I get is "Reload" but this is what Terminal looks like after pressing return in terminal was that right?

                                    The Terminal screenshot looks as if you left off part of the command. Did you type the entire line

                                    defaults write com.google.sketchuppro8 WebKitDeveloperExtras -bool true

                                    I forgot to mention that before entering this command you should quit SketchUp and restart it afterward. Until the default takes hold the right-click menu will only contain "Reload".

                                    Steve

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • M 離線
                                      mwm5053
                                      最後由 編輯

                                      I double checked the terminal and retyped and restated SU still no right click web inspector?


                                      Screen Shot 2014-02-16 at 8.19.17 PM.png

                                      2011 iMac
                                      SU 2015 Pro, 2017 Make
                                      V2 Twilight
                                      macOS Sierra 10.12.5

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • S 離線
                                        slbaumgartner
                                        最後由 編輯

                                        @mwm5053 said:

                                        I double checked the terminal and retyped and restated SU still no right click web inspector?

                                        Missed it again! You typed com.google.sketchup8pro, it should be com.google.sketchuppro8

                                        Steve

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • M 離線
                                          mwm5053
                                          最後由 編輯

                                          👍

                                          2011 iMac
                                          SU 2015 Pro, 2017 Make
                                          V2 Twilight
                                          macOS Sierra 10.12.5

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • M 離線
                                            mwm5053
                                            最後由 編輯

                                            I don't understand why right click won't bring up Inspect Element?


                                            Screen Shot 2014-02-16 at 8.33.40 PM.png

                                            2011 iMac
                                            SU 2015 Pro, 2017 Make
                                            V2 Twilight
                                            macOS Sierra 10.12.5

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement