16 Replies Latest reply on May 17, 2017 12:22 AM by Laubender

    Compiled scripts in 2015

    Pickory Level 3

      Hello,

       

      I have a few compiled scripts that work in CC 2014 but crash in CC 2015. The scripts are run from a separate script file with a do script command.

       

      #targetengine "myengine";

      main ();

       

      function main ()

      {

      var myscript = "the compiled script code goes here";

      app.doScript( myscript );

        • 1. Re: Compiled scripts in 2015
          Pickory Level 3

          Ooops, pressed command s, now I can't edit it.

           

          Just wanted to say. Has anyone else seen this?

           

          Thanks.

           

          P.

          • 2. Re: Compiled scripts in 2015
            Ronald63 Level 4

            Hi,

             

            I have the same problem and I have not yet found a solution

             

            Ronald

             


            • 3. Re: Compiled scripts in 2015
              Harbs. Level 6

              What do you mean by compiled script? Do you mean JSXBIN content?

              • 4. Re: Compiled scripts in 2015
                Pickory Level 3

                Hello Harbs,

                 

                Yes, JSXBIN. All the crashing scripts are trying to create a palette. When run as JSX the scripts work. They all seem to crash when adding items to the palette.

                 

                P.

                • 5. Re: Compiled scripts in 2015
                  Pickory Level 3

                  Well, these scripts work on Windows 8 and Win 7. Where do we report this?

                   

                  ===============

                  0   libobjc.A.dylib              0x0000000102aa1097 objc_msgSend + 23
                  1   com.apple.CoreFoundation      0x0000000102d53ba8 CFURLGetFileSystemRepresentation + 184
                  2   com.adobe.AFL                0x000000010c693be7 adobe::afl::MacFileUtils::CFURLRefToAFile(__CFURL const* const&, adobe::afl::AFile&) + 61
                  3   PublicLib.dylib              0x000000010c149e60 MFileUtility::ResolveSpec() + 1120
                  4   PublicLib.dylib              0x000000010c1499e8 MFileUtility::GetSysFile() + 24
                  5   PublicLib.dylib              0x000000010c154444 FileUtils::PMStringToIDFile(PMString const&, IDFile&) + 52
                  6   PublicLib.dylib              0x000000010c3431a3 ScriptData::GetFile(IDFile*, ScriptInfo::RequestContext const&, short) const + 339
                  7   PublicLib.dylib              0x000000010c36f117 ScriptInfo::TypeInfo::IsValidValue(ScriptData const&, ScriptInfo::ObjectScriptElement const*) const + 3431
                  8   PublicLib.dylib              0x000000010c36e554 ScriptInfo::TypeInfo::IsValidValue(ScriptData const&, ScriptInfo::ObjectScriptElement const*) const + 420
                  9   com.adobe.InDesign.Scripting  0x000000011bab31eb 0x11ba89000 + 172523
                  • 6. Re: Compiled scripts in 2015
                    Ronald63 Level 4

                    I solved my problem by replacing app.doScript( myscript )  by eval(myscript).

                    • 7. Re: Compiled scripts in 2015
                      Pickory Level 3

                      Well done!

                       

                      I wonder what the implications are, changing to eval.

                       

                      Thanks.

                       

                      P.

                      • 8. Re: Compiled scripts in 2015
                        Laubender Adobe Community Professional & MVP

                        Hi, Pickory!
                        I had all the same.

                         

                        InDesign CC-2015 was crashing after executing a jsx file containing some binary code (amongst other plain code), that was started by the method doScript().

                        I did not write the code for this example, just was using the script, did not have the source. Fortunately the line with doScript() was in plain code, so I could change this with eval().

                        Where eval() evaluated the first argument of doScript(). That did the trick. No crashes anymore.

                         

                        Implications? Yes:
                        All arguments, but the first one, that is given to doScript(), will not be honored:

                        The undo-mechanism UndoModes.FAST_ENTIRE_SCRIPT with doScript(), cannot work anymore.

                        Or the script language statement, if that is important.

                        Or other arguments you are feeding.

                         

                        Uwe

                        • 9. Re: Compiled scripts in 2015
                          Pickory Level 3

                          Hello Uwe,

                           

                          Thanks for clarifying that.

                           

                          Shame about the undo, I wonder if you could wrap the eval in a do script. ( I'm not going to do it!).

                           

                          P.

                          • 10. Re: Compiled scripts in 2015
                            Trevorׅ Adobe Community Professional

                            Hello All

                            I was wondering what happens when you wrap the doScript with an eval and what happens when you wrap the eval with the doScript

                            Wrapping the eval with the doScript does not help and the app will still crash, however wrapping the doScript will an eval does work and that way one can use all the doScript arguments like script language, arguments, and undo mode.

                            See the snippets below in pain and binary form.

                            var isMac = $.os[0] === "M",
                                sl = isMac ? ScriptLanguage.APPLESCRIPT_LANGUAGE : ScriptLanguage.VISUAL_BASIC,
                                theScript = isMac ? 'display dialog "Hello from applescript"' : 'msgBox "Hello from VISUAL BASIC"';
                            app.doScript (theScript, sl);
                            var js = 'var n; for (n in arguments) alert (arguments[n]);'
                            app.doScript (js, ScriptLanguage.JAVASCRIPT, ["Hello From Arguments"]);
                            js = '''#targetengine undo test;
                                    var doc, tf, p;
                                    doc = app.documents.add();
                                    p = doc.pages[0];
                                    tf = p.textFrames.add();
                                    tf.geometricBounds = p.bounds;
                                    tf.fillColor = doc.colors.itemByName("Yellow");
                                    tf.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
                                    tf.contents = "Hello there\\nDo undo to test if the undo mode has been set\\nIf it has then the whole text frame will disappear.\\nIf not then only this message will disappear but the text frame will stay YELLOW";
                                    tf.paragraphs.everyItem ().justification = Justification.CENTER_ALIGN;
                                    var w = new Window('palette'),
                                        b = w.add('button', undefined, "Undo?"),
                                        c = w.add('button', undefined, "Close");
                                    b.onClick = function () {doc.undo();};
                                    c.onClick = function () {w.close();};
                                    w.show();
                                 ''';
                            app.doScript (js, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Clear Page Undo Test");
                            
                            

                             

                            eval('''@JSXBIN@ES@2.0@MyBbyBn0AGbBn0ADJBnASzFjJjTiNjBjDByBCzDhdhdhdCXzBhQDfXzCjPjTEfjzB
                            hEFfnneBiNnftJCnASzCjTjMGyBdVBfyBXzUiBiQiQiMiFiTiDiSiJiQiUifiMiBiOiHiViBiHiFHfj
                            zOiTjDjSjJjQjUiMjBjOjHjVjBjHjFIfXzMiWiJiTiViBiMifiCiBiTiJiDJfjIfnftJDnASzJjUjIj
                            FiTjDjSjJjQjUKyBdVBfyBFehHjEjJjTjQjMjBjZhAjEjJjBjMjPjHhAhCiIjFjMjMjPhAjGjSjPjNh
                            AjBjQjQjMjFjTjDjSjJjQjUhCFehAjNjTjHiCjPjYhAhCiIjFjMjMjPhAjGjSjPjNhAiWiJiTiViBiM
                            hAiCiBiTiJiDhCnftJEnAEXzIjEjPiTjDjSjJjQjULfjzDjBjQjQMfRCVKfyBVGfyBffJFnASzCjKjT
                            NyBnehRjWjBjShAjOhbhAjGjPjShAhIjOhAjJjOhAjBjSjHjVjNjFjOjUjThJhAjBjMjFjSjUhAhIjB
                            jSjHjVjNjFjOjUjTibjOidhJhbftJGnAEXLfjMfRDVNfyBXzKiKiBiWiBiTiDiSiJiQiUOfjIfARBFe
                            UiIjFjMjMjPhAiGjSjPjNhAiBjSjHjVjNjFjOjUjTfffJHnASNyBne2jZDhDjUjBjSjHjFjUjFjOjHj
                            JjOjFhAjVjOjEjPhAjUjFjTjUhbKhAhAhAhAhAhAhAhAjWjBjShAjEjPjDhMhAjUjGhMhAjQhbKhAhA
                            hAhAhAhAhAhAjEjPjDhAhdhAjBjQjQhOjEjPjDjVjNjFjOjUjThOjBjEjEhIhJhbKhAhAhAhAhAhAhA
                            hAjQhAhdhAjEjPjDhOjQjBjHjFjTibhQidhbKhAhAhAhAhAhAhAhAjUjGhAhdhAjQhOjUjFjYjUiGjS
                            jBjNjFjThOjBjEjEhIhJhbKhAhAhAhAhAhAhAhAjUjGhOjHjFjPjNjFjUjSjJjDiCjPjVjOjEjThAhd
                            hAjQhOjCjPjVjOjEjThbKhAhAhAhAhAhAhAhAjUjGhOjGjJjMjMiDjPjMjPjShAhdhAjEjPjDhOjDjP
                            jMjPjSjThOjJjUjFjNiCjZiOjBjNjFhIhCiZjFjMjMjPjXhChJhbKhAhAhAhAhAhAhAhAjUjGhOjUjF
                            jYjUiGjSjBjNjFiQjSjFjGjFjSjFjOjDjFjThOjWjFjSjUjJjDjBjMiKjVjTjUjJjGjJjDjBjUjJjPj
                            OhAhdhAiWjFjSjUjJjDjBjMiKjVjTjUjJjGjJjDjBjUjJjPjOhOiDiFiOiUiFiSifiBiMiJiHiOhbKh
                            AhAhAhAhAhAhAhAjUjGhOjDjPjOjUjFjOjUjThAhdhAhCiIjFjMjMjPhAjUjIjFjSjFicjOiEjPhAjV
                            jOjEjPhAjUjPhAjUjFjTjUhAjJjGhAjUjIjFhAjVjOjEjPhAjNjPjEjFhAjIjBjThAjCjFjFjOhAjTj
                            FjUicjOiJjGhAjJjUhAjIjBjThAjUjIjFjOhAjUjIjFhAjXjIjPjMjFhAjUjFjYjUhAjGjSjBjNjFhA
                            jXjJjMjMhAjEjJjTjBjQjQjFjBjShOicjOiJjGhAjOjPjUhAjUjIjFjOhAjPjOjMjZhAjUjIjJjThAj
                            NjFjTjTjBjHjFhAjXjJjMjMhAjEjJjTjBjQjQjFjBjShAjCjVjUhAjUjIjFhAjUjFjYjUhAjGjSjBjN
                            jFhAjXjJjMjMhAjTjUjBjZhAiZiFiMiMiPiXhChbKhAhAhAhAhAhAhAhAjUjGhOjQjBjSjBjHjSjBjQ
                            jIjThOjFjWjFjSjZiJjUjFjNhAhIhJhOjKjVjTjUjJjGjJjDjBjUjJjPjOhAhdhAiKjVjTjUjJjGjJj
                            DjBjUjJjPjOhOiDiFiOiUiFiSifiBiMiJiHiOhbKhAhAhAhAhAhAhAhAjWjBjShAjXhAhdhAjOjFjXh
                            AiXjJjOjEjPjXhIhHjQjBjMjFjUjUjFhHhJhMKhAhAhAhAhAhAhAhAhAhAhAhAjChAhdhAjXhOjBjEj
                            EhIhHjCjVjUjUjPjOhHhMhAjVjOjEjFjGjJjOjFjEhMhAhCiVjOjEjPhfhChJhMKhAhAhAhAhAhAhAh
                            AhAhAhAhAjDhAhdhAjXhOjBjEjEhIhHjCjVjUjUjPjOhHhMhAjVjOjEjFjGjJjOjFjEhMhAhCiDjMjP
                            jTjFhChJhbKhAhAhAhAhAhAhAhAjChOjPjOiDjMjJjDjLhAhdhAjGjVjOjDjUjJjPjOhAhIhJhAjbjE
                            jPjDhOjVjOjEjPhIhJhbjdhbKhAhAhAhAhAhAhAhAjDhOjPjOiDjMjJjDjLhAhdhAjGjVjOjDjUjJjP
                            jOhAhIhJhAjbjXhOjDjMjPjTjFhIhJhbjdhbKhAhAhAhAhAhAhAhAjXhOjTjIjPjXhIhJhbKhAhAhAh
                            AhAffJYnAEXLfjMfRFVNfyBXOfjIfjzJjVjOjEjFjGjJjOjFjEPfXzSiGiBiTiUifiFiOiUiJiSiFif
                            iTiDiSiJiQiUQfjzJiVjOjEjPiNjPjEjFjTRfFeUiDjMjFjBjShAiQjBjHjFhAiVjOjEjPhAiUjFjTj
                            UffAEK4C0AiAB40BiAG4B0AiAN4D0AiAAEAzASByB''');
                            
                            

                             

                            I think that this is going to be the way to go.

                             

                            HTH

                             

                            Trevor

                             

                            P.s. The example here only contains 1 argument but if you add other arguments to the argument array it will pass all of them

                            • 11. Re: Compiled scripts in 2015
                              Laubender Adobe Community Professional & MVP

                              Hi, Trevor!
                              Thank you very much.

                               

                              As I understand the issue, to crash InDesign CC-2015:

                              1. We need a Window of type "palette"

                              2. We have to add something to that window, eg. a button

                              3. We need a doScript(), that is executing the code where the part of the window creation is in binary encoding executed by the doScript() (??)

                               

                              It will work and not crash InDesign, if we use eval().

                              And a schema, something like the one below, will work for maintaining the undo mode.

                              I already tested the following code where the bin parts are:

                              a.) fully written in one line and

                              b.) are unabridged.

                               

                              So far so good:

                               

                              //DUMMY CODE IN eval() !!!
                              #targetengine "myDoScriptEngine"
                              //function doSomething() is evaluated by eval():
                              
                              eval('''@JSXBIN@ES@2.0@MyBbyBnABMAbyBn . . . OjHOAJ0EzAPByB''');
                              
                              //~ function doSomething(){
                              
                              //~   var myDoc = app.documents.add();
                              //~   myDoc.pages[0].rectangles.add(
                              //~     {
                              //~         geometricBounds : myDoc.pages[0].bounds, 
                              //~         fillColor : myDoc.colors.itemByName("Yellow")
                              //~     });
                              
                              //~ };
                              
                              //Undo mode maintained:
                              
                              app.doScript
                                  (
                                 
                                  doSomething,
                                  ScriptLanguage.JAVASCRIPT,
                                  [],
                                  UndoModes.ENTIRE_SCRIPT,
                                  "Do Something | SCRIPT"
                                 
                                  );
                              
                              //function setPaletteWindow(){} in binary form evaluated by eval():
                              
                              eval('''@JSXBIN@ES@2.0@MyBbyBnABMAbyBn0AGJCn . . . XjJjOjEjPjXRAJ0EMB''');
                              
                              //~ function setPaletteWindow(){
                              //~     
                              //~     var w = new Window('palette');
                              //~     var b = w.add('button', undefined, "Undo?"); 
                              //~     var c = w.add('button', undefined, "Close");
                              //~     b.onClick = function () {app.documents[0].undo();};
                              //~     c.onClick = function () {app.documents[0].close(SaveOptions.NO); w.close();};
                              //~     w.show();
                              //~     
                              //~ };
                              
                              //function call after evaluation of the function:
                              setPaletteWindow();
                              

                               

                               

                              But I still struggle to create a basic script exported to jsxbin file format, that will crash my InDesign CC-2015.

                              The code above written all out in plain code (see the commented lines) without the eval() parts exported to jsxbin will work for the doSomething() part, it will not crash InDesign CC-2015.

                              But unfortunately the palette window will not show up either.

                              Why is that?

                              Should be parts of the code in different order?

                              I'm on Mac OSX 10.10.3.

                               

                              On the other hand I have one case, a very complex one, where parts of the code are in binary encoding and parts of it are in plain text where exactly that happens: Crashing InDesign CC-2015.

                              I cannot analyze this, because it is not written by me and the source is not available. And it's a mammoth of a script.

                               

                              Any clues how to crash InDesign then? ;-)

                               

                              Uwe

                              • 12. Re: Compiled scripts in 2015
                                Pickory Level 3

                                Hello,

                                 

                                All of my scripts that crash add a group, then add buttons etc.

                                 

                                P.

                                • 13. Re: Compiled scripts in 2015
                                  Trevorׅ Adobe Community Professional

                                  Hi Uwe,

                                   

                                  If you run my binary with a doScript instead of an eval does is not make 2015 crash by you?

                                  I did a bit of experimenting and the result were:

                                  If I removed the lines 1 - 6 and complied the code and used a doScript it will crash 2015, this method has the script in a string, no need to set the #target engine outside of the doScript

                                  If I removed the lines 1 - 7 and 23 and 24 and complied the code and used a doScript it will not crash 2015 (In this case I need to set the #target engine outside of the doScript)

                                  If instead of having the js as a string I have it as a function complied the code and used a doScript it will not crash 2015 (In this case I need to set the #target engine outside of the doScript)

                                   

                                  js = '#targetengine undo test;\
                                          var doc, tf, p;\
                                          doc = app.documents.add();\
                                          p = doc.pages[0];\
                                          tf = p.textFrames.add();\
                                          tf.geometricBounds = p.bounds;\
                                          tf.fillColor = doc.colors.itemByName("Yellow");\
                                          tf.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;\
                                          tf.contents = "Hello there\\nDo undo to test if the undo mode has been set\\nIf it has then the whole text frame will disappear.\\nIf not then only this message will disappear but the text frame will stay YELLOW";\
                                          tf.paragraphs.everyItem ().justification = Justification.CENTER_ALIGN;\
                                          var w = new Window("palette"),\
                                              b = w.add("button", undefined, "Undo?"),\
                                              c = w.add("button", undefined, "Close");\
                                          b.onClick = function () {doc.undo();};\
                                          c.onClick = function () {w.close();};\
                                          w.show();\
                                       ';
                                  app.doScript (js, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Clear Page Undo Test");
                                  

                                   

                                  compiling the above, replacing the ''' with \ will not crash 2015

                                  js = '''alert('Hello');
                                  alert("""Uwe""");
                                  ''';
                                  app.doScript (js, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Clear Page Undo Test");
                                  

                                   

                                   

                                  compiling the above, will not crash 2015

                                   

                                  Pickory are you using triple ''' ?

                                   

                                  Bingo?

                                  js = '''#targetengine undo test;  
                                          var doc, tf, p;  
                                          doc = app.documents.add();  
                                          p = doc.pages[0];  
                                          tf = p.textFrames.add();  
                                          tf.geometricBounds = p.bounds;  
                                          tf.fillColor = doc.colors.itemByName("Yellow");  
                                          tf.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;  
                                          tf.contents = "Hello there";
                                          tf.paragraphs.everyItem ().justification = Justification.CENTER_ALIGN;  
                                          var w = new Window('palette'),  
                                              b = w.add('button', undefined, "Undo?"),  
                                              c = w.add('button', undefined, "Close");  
                                          b.onClick = function () {doc.undo();};  
                                          c.onClick = function () {w.close();};  
                                          w.show();  
                                       ''';  
                                  app.doScript (js, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Clear Page Undo Test"); 
                                  

                                   

                                  compiling the above, will not crash 2015


                                  js = '''#targetengine undo test;  
                                          var doc, tf, p;  
                                          doc = app.documents.add();  
                                          p = doc.pages[0];  
                                          tf = p.textFrames.add();  
                                          tf.geometricBounds = p.bounds;  
                                          tf.fillColor = doc.colors.itemByName("Yellow");  
                                          tf.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;  
                                          tf.contents = "Hello there\\nDo undo to test if the undo mode has been set\\nIf it has then the whole text frame will disappear.\\nIf not then only this message will disappear but the text frame will stay YELLOW";  
                                          tf.paragraphs.everyItem ().justification = Justification.CENTER_ALIGN;  
                                       ''';  
                                  
                                  


                                  compiling the above, will not crash 2015.


                                  So what seems to be causing it is a combination of tripple ''' and a palette and the \\n

                                  Ok there might be some other causes

                                  But the important thing is the solution which is to do the doScript stuff in the binary and apply the eval to that.



                                  Please excuse my bolding

                                   

                                  Trevor

                                  • 14. Re: Compiled scripts in 2015
                                    Laubender Adobe Community Professional & MVP

                                    If you run my binary with a doScript instead of an eval does is not make 2015 crash by you?

                                     

                                    Hi Trevor,

                                    indeed running your binary with doScript() will indeed crash InDesign CC-2015. Not CC-2014 (also tested).

                                     

                                    //Crashing InDesign CC-2015
                                    //Is not crashing CC-2014 and running as expected
                                    
                                    //Trevor's binary code abridged here:
                                    var myScript = '''@JSXBIN@ES@2.0@MyBbyBn0AG . . . BiAG4B0AiAAEAzASByB'''
                                    app.doScript(myScript);
                                    

                                     

                                    Then went on with your example using the single quotes and the escape characters for newline and the double escapes in applying the contents.

                                     

                                    I copy/pasted your code to my ESTK on Mac OSX 10.10.3 and had this:

                                     

                                    CodeCopiedFromTheForum.png

                                     

                                    It seems that the ESTK couldn't deal with the escapes at the end of the lines. So I changed them to:

                                     

                                    FormattedThisWayNoProblem.png

                                     

                                    Exported to jsxbin and it all ran fine in CC-2015.

                                     

                                    Also tried your code below Bingo?. Also ran fine when exported to jsxbin.

                                     

                                    "So what seems to be causing it is a combination of tripple ''' and a palette and the \\n"

                                    Ah. That's it. Now, who is writing the bug report?

                                     

                                    Uwe

                                    • 15. Re: Compiled scripts in 2015
                                      Trevorׅ Adobe Community Professional

                                      Hi Uwe,

                                       

                                      As a MVP I'll leave the bug report to you

                                      Regarding the \ not working that is because the forum appends a space at the  end of each line before the carriage return. You can see these extra spaces on your screenshot and also when you you select the code.

                                      If you used Sublime Text theirs a package that all ways highlights the  and you can easily remove them.

                                      Screen Shot 2015-07-21 at 14.46.32.png

                                       

                                      Trevor

                                      1 person found this helpful
                                      • 16. Re: Compiled scripts in 2015
                                        Laubender Adobe Community Professional & MVP

                                        Hi Trevor,

                                        it's been a while that this thread went live.

                                         

                                        FWIW: I tested the old code, that crashed one of my older versions of InDesign CC 2015 again with my current version of CC 2015.4.1.

                                        Also with CC 2017.1 and could not detect any crash. So the bug was fixed during the last iterations of CC 2015.

                                         

                                        Tests done on German OSX 10.10.5 with German InDesign.

                                         

                                        // EDIT:
                                        Just went back to one of my old crash reports.
                                        The exact version of InDesign CC 2015 where the code crashed was:

                                        11.0.1.105

                                         

                                        Not so with:

                                        11.4.1.102

                                         

                                        Case closed, I think.

                                         

                                        Regards,
                                        Uwe