[Request] Testing on a Mac
-
Could some kind person(s) have a look at this plugin code? I'm told it does not work on a Mac (I only have a PC). I have gone through all the javascript and transformed all IE only syntax. Perhaps a cursory look at the attached files is enough to expose the cause.
Many thanks
Chris
-
you can always download Safari for Windows and try things out.
on a quick look it seems that count variable is not defined in start() function and screws things out.
-
@unknownuser said:
you can always download Safari for Windows and try things out.
on a quick look it seems that count variable is not defined in start() function and screws things out.
Thanks TBD.
Yes I have downloaded Safari but the code is so mixed up with Sketchup, I would need to make a whole lot of fake SU returns - maybe I will just have to do that.
The count variable is received from the ruby callback further down the page. I moved it up to make the code easier to read. Everything seems to work in a PC so I think it must be syntax related or possibly something to do with entities at the beginning (I saw something about that but I cannot remember where).
Any further help gratefully received!
My regards
Chris
-
OK found it
@unknownuser said:
Finally, there is a difference in the way that the Mac boots up SketchUp that you should be cautious about: there is no Sketchup.active_model when the Ruby scripts are first loaded. So if your script is making changes to the active_model at load time, it will not work on the Mac. The answer? Ensure code that references the active model is part of a UI event handler, responding to the user selecting a tool or a menu item. You can also use an AppObserver to get a callback whenever a new model is opened, at which point it's safe to talk to the active_model.
Anyone kind enough to help with the observer code?
Chris
-
I always do me coding outside of Sketchup using a proxy function for Sketchup related functions. This way I can do the testing easily,without waiting for Sketchup and with proper debug tools.
I would do some refactoring and add a proxy Sketchup function to test things in Safari.
if you need some small code to be tested on Mac - post it and I try it.
-
@unknownuser said:
if you need some small code to be tested on Mac - post it and I try it.
Thanks I can make a small example (thanks for the offer); but if you don't test it with Sketchup (but a proxy) how does the active model business fit in?
Chris
-
Here are html and rb files that open three scenes onloading. They work on a PC.
Thanks
Chris
-
ok, this is weird.
if I don't add the alerts the code doesn't get run. looks like some synchronization problems from HTML world to SketchUp world.
need to debug this further.
-
@unknownuser said:
ok, this is weird.
if I don't add the alerts the code doesn't get run. looks like some synchronization problems from HTML world to SketchUp world.
need to debug this further.
Sorry to have lumbered you with this.
The thing works on my PC with or without the alerts (but I expect you would have guessed that).
Do you think I should try and get the Sketchup team to look at it. CMD showed an interest in cgScenes so maybe he (or she) could help. Please let me know what you think.
And thanks again of course.
Chris
-
Unless I misunderstand the problem, SketchUp always uses Internet Explorer no matter what other browser is installed.
-
@jim said:
Unless I misunderstand the problem, SketchUp always uses Internet Explorer no matter what other browser is installed.
On PC, yes. But on Mac it uses the Safari engine.
So when you're on PC developing a plugin - with no Mac to test on you can try your code on Safari to do some basic testing.
If you're on Mac it's worse though as IE hasn't been available on Mac since IE5 - and even then it was a completely different browser than the PC version. -
If this Mac testing isn't too urgent I could have a look at it. But I don't have much spare time as I'm working on an architectural project besides work which is due on ~2 weeks. +pluss my involvement in other projects and various beta testings.
But I do have a Mac Mini at home that I've used to debug ruby plugins. -
[First off, thanks to TBD for forwarding the link to me..]
I never did really understand what it is you're trying to do, Chris, but the example TBD posted can be made to work by editing line 16 of sceneTest.rb to be:
cmd = "receiveSceneCount('#{count}')"
Guess they're not handling the (admittedly spurious) terminator correctly.
Adam
-
Thanks all!
It is pretty late here, and I have only the energy to copy post my reply to Jim's PM ...
Thanks Jim, this Mac business is very troublesome. I found the following in the API documentation:
@unknownuser said:
Finally, there is a difference in the way that the Mac boots up SketchUp that you should be cautious about: there is no Sketchup.active_model when the Ruby scripts are first loaded. So if your script is making changes to the active_model at load time, it will not work on the Mac. The answer? Ensure code that references the active model is part of a UI event handler, responding to the user selecting a tool or a menu item. You can also use an AppObserver to get a callback whenever a new model is opened, at which point it's safe to talk to the active_model.
I looked at the AppObserver class, but as I have no experience of observers and I will have limited time with the Mac tomorrow, I thought if someone could help with the observer mentioned, I might just have a chance.
I'll post this in the topic as well.
My regards
Chris
-
that code will never work race condition - JS code will run before the Ruby thing so you will get wrong values. that's why it works only when alert commands are inserted (which is not a solution imho)
you need to refactor the code and take that in account (or push Google to open their implementation of JS bridge from DC)
-
http://forums.sketchucation.com/viewtopic.php?f=315&t=19831&st=0&sk=t&sd=a&start=45#p165464
@unknownuser said:
On the WebDialog topic...
We wrote a somewhat generic bridge between JS and Ruby that we used for Dynamic Components. I learned a lot from that and would have some thoughts on how to build a new one that's truly generic and easy to use. That's almost worthy of its own big thread.
One note: I think it would be work for the JS code side of a bridge to be stored in the ruby and then dumped into the WebDialog via execute_script, so JS code side of things would call something like this:
Code: Select all
window.location.href='skp:initialize_bridge';...and then from there would have access to whatever JS methods we implement.
It doesn't sound like Google wants to open their code, but Scott says he is willing to help design a better bridge.
-
Thanks for all your help. In the end with the constraints of machinery and time, I decided to resort to the good old 1995 solution:
function start(){ if(navigator.appName == 'Microsoft Internet Explorer') browserStart() else{ confirmPanel = document.getElementById("confirm") confirmPanel.innerHTML = "START" } } function receiveSceneCount(x){ count = x } function browserStart(){ //TO FIND IF ANY SCENES EXIST .... function confirmDown(){ switch(confirmPanel.innerHTML){ case "START"; browserStart(); break ....
I hope it works but it really doesn't seem right.
Also I think it is wrong to start off a major new excursion into automated interfaces with workarounds! I would really like to find a proper solution. Perhaps the evolution of SKX will help expose it - but I wonder how.
Anyway thanks again for your time; I will let you know what happened tonight tomorrow; I foresee some grief!
Kind regards
Chris
-
hmm... It might be that you try to do changes to the webpage before the DOM is ready. If you do things immediately as the webdialog is loaded you need to wait until all the HTML elements are built.
http://www.javascriptkit.com/dhtmltutors/domready.shtml -
I think I will look at that deeply if the thing fails tonight because everything now seems to work with a PC; and I have loaded the page into Safari and there are no syntax errors (tested with FF as well) just complaints about skp of course. So I don't want to mess with what exists.
It seems to me this is much the same as loading the active_model business. Anyway thanks for the info. I just hope I don't need to re-jig everything!
Cheers
Chris
-
@chrisglasier said:
Could some kind person(s) have a look at this plugin code? I'm told it does not work on a Mac (I only have a PC). I have gone through all the javascript and transformed all IE only syntax. Perhaps a cursory look at the attached files is enough to expose the cause.
Many thanks
Chris
Chris,
You may just be facing a well-known synchronization issue with web dialogs on Mac. Unlike in Windows/IE, the
windows.location
callback verb called from HTML does NOT block, so that you continue execute JavaScript. Furthermore, most callbacks will be 'lost', as Sketchup uses only one buffer to communicate with Ruby, not a queue.See that post: http://forums.sketchucation.com/viewtopic.php?f=180&t=13394&p=101428&hilit=+safari#p98793
You have to do the synchronization manually, which, I agree, is not a piece of cake.
Fredo
Advertisement