The Bug from Hell, Redux
-
An odd bug bit me, and bit hard, on my way to releasing my first serious Ruby.
The bug was in the communication from JS to Ruby to JS. The problem was that a JS-built WebDialog prepared before the body of the HTML holding the JS was complete had a bug. It could not execute_script().
The full-length version of The Bug from Hell, including two cameo appearances of Monty, my pet python, is here: http://21st-century-languages.blogspot.com/2009/08/bug-from-hell.html
Now my Ruby is ready for release except that it does not pass my last test: run successfully on a larger model (two-dozen layers, three-dozen scenes, 3MB .skp). The basic idea is this:
In Ruby get-the-data callback, assemble JSON data based on model; assemble script to call JS function with JSON data; puts script (it's fine); WebDialog.execute_script( script ).
The first line of the JS receiver is an alert, showing the JSON. Same as in the Bug from Hell, it never gets there. Unlike the Bug from Hell, which reported nothing, IE reports an error at line 119993461, character 828, "Expected ')'".
The only (really?) difference between the test cases and the final test is size. The script to be executed was about 2KB. I cut out half the scenes, reducing the script to about 1100B. Same problem.
Anyone else been here?
-
Progress?
Added this, at the beginning of the Ruby callback:
script = 'rubyReturned( "Hi, JS, how ya doin\'" )' js_wd.execute_script( script )
The JS 'rubyReturned' function popped the message up in an alert box, so it was called and executed correctly. Then got an error on the next line of JS (reasonable, since "Hi, JS, how ya doin'" is not valid JSON).
The troubling error, at the ridiculous line number, pops next. This is the offending script:
rubyReturned( "{ layers;[ 'Layer0', 'basement', 'basement_ceiling', 'ground_floor', 'apartment_floor', 'apartment_built_ins', 'hidden', 'apartment_furniture', 'apartment_inside_walls', 'outside_wall_front', 'outside_wall_right', 'outside_wall_back', 'outside_wall_left', 'attic', 'roof_front', 'roof_back' ], scenes;[ '01 start', '02 outside, back-left', '03 outside, back-right', '04 outside, front-right', '05 outside, zoom out', '06 outside, closer, no apartment', '07 outside, close, no apartment floor', '08 outside, close, no ground floor', '09 above, basement', '10 above, basement w/ceiling', '11 above, carriage garage', '12 outside apartment door', '13 outside, apartment added', '14 above apartment, wo roof_front', '15 outside apartment, wo outside_wall_front', '16 outside, facing dinette and attic', '17 outside "ladder", w outside_wall_front', '18 outside facing livingroom, roof_front replaces roof_back', '19 zoom in to livingroom' ], vis;'VVVVVVVVVVVVVVVVVVVIIIIIIIVVVVVVVVVVVVVVVVVVVVIVVVVVVVVVVVVVVVVVIIIVVVVVVVVVVVVVVVIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVVVIIIIIIIIIIIIIIIIIIIVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVIIVVVVVVVVIIIIIIIVVVVVVVVVVVVIIIIIIIVVVVVIIVVVVVIIIIIIIVVVIIIIIIIIIIIIIIIIIVVVIIIVVVVVIIIIIIIVIIIIVVVVVVVIIIIIIIVVVVVII' }" );
-
Martin,
When writing a component stepper and a layer stepper, I had to escape () both single and double quotes everywhere when used in string data passed to a JS function using execute_script.
Greg
-
@msp_greg said:
When writing a component stepper and a layer stepper, I had to escape () both single and double quotes everywhere ...
Thanks! Bug gone.
Advertisement