6 Replies Latest reply on Mar 4, 2013 1:13 PM by Laubender

    error explanation

    bduffy323 Level 1

      I have finally wittle down an error that has been occurring in my much larger project to just a couple lines of code to simply reproduce the error. It errors on PC and MAC cs5.5. Here are the scripts/process of how to recreate the error.

       

      start-up script to define the engine: jumpStarter.jsx

      #targetengine "testEngine"
      
      var globalVar = "testing";
      

       

      script that calls another via doScript: globalTest.jsx

      #targetengine "testEngine"
      
      setLabel();
      
      function setLabel(myParams)
      {
          var myFile = new File(app.filePath + "/Scripts/Scripts Panel/testScript.jsx");
          app.doScript(myFile,ScriptLanguage.JAVASCRIPT,undefined,UndoModes.fastEntireScript);
      }
      
      

       

      script that adds a label to the document: testScript.jsx

      #targetengine "testEngine"
      doStuff()
      
      function doStuff()
      {
          app.activeDocument.rectangles.add();
          app.activeDocument.insertLabel("tempLabel","anyLabel");
          //app.activeDocument.updateCrossReferences();
      }
      
      

       

       

      The process is simple. Simply put the jumpStarter.jsx in the start up folder and the other two scripts in the scripts panel folder. Load up Indesign and double click the globalTest.jsx from the scripts panel. You should see a rectangle get placed on the page and an * next to the filename. If you then close the document and choose not to save it Indesign should crash. I am interested in knowing what is causing this crash!

       

      Side note: After days of attempts I came across the commented out line of code in testScript.jsx. If this line is uncommented then there are no issues upon closing the document! However I am not sure what that method is actually doing and after researching what cross references are it didn't seem applicapable. I am also looking for someone to explain this if possible.

       

      Here is the protectiveShutdownlog that gets produced: http://pastebin.com/04pHQv5s

      Here is the crash report that gets produced: http://pastebin.com/JA6esJR2

        • 1. Re: error explanation
          MrTIFF Level 3

          (CS5 Mac) -- this is strange -- I got 2 main results:

           

          1. If I run from ESTK instead of the Scripts Panel, no crash.

           

          2. Perhaps more usefully, if you change the name of your global variable from "globalVar" to "g_globalVar", no crash.

           

          Tentative conclusion: "globalVar" might be some kind of hidden "reserved" name in global space, used for some other purpose by ExtendScript.

           

          These days, I usually put my functions and 'global' variables in a separate namespace object, to avoid any possible name conflicts.

          • 2. Re: error explanation
            Marc Autret Level 4

            Hi bduffy,

             

            As far as I have experienced this bug appeared in ID CS5 and is not solved yet. It is not related to the use of a startup script, a persistent engine, app.docript(), etc., and it has no connection with global variables, variable names, etc.

             

            The bug typically occurs when:

             

            1) A script inserts a label into the active document;

            2) Once the script has finished, the user attempts to close the active document and does not save it.

             

            Minimal code that should lead to the bug:

             

            app.activeDocument.insertLabel('foo','bar');

            // then the user go to  File > Close


            My own speculation about the causes of this bug:


            The internal pointer which holds app.activeDocument is not properly updated after insertLabel() is done. Maybe at some level the subsystem does not identify the label insertion as an actual modification and forgets to refresh some underlying specifier... Who knows?

             

            Patch:

             

            I found that just accessing the property app.activeDocument at the end of the script usually fixes the instability, as this probably causes the system to recalculate the document specifier:

             

            app.activeDocument.insertLabel('foo','bar');

            app.activeDocument; // patch

            // => no bug


            As a stronger and safer approach, I suggest you add this line at the end of any script:

             

            app.properties.activeDocument && app.activeDocument.getElements();

             

            Of course this is all without warranty!

             

            Hope that helps.

             

            @+

            Marc

            • 3. Re: error explanation
              Laubender Adobe Community Professional & MVP

              InDesign CS5 v7.0.4.553 (German)

              InDesign CS5.5 v7.5.3.333 (German)
              Mac OSX 10.6.8 (German)
              MacBook Pro

               

              @bduffy – I experience a crash when using your set of scripts in InDesign CS5 (without using the ESTK).


              After a restart of the crashed InDesign app the changed file will be opened again (the usual repair mechanism of InDesign kicks in) and then could be closed without saving. No crash at this point.

               

              No problems running "globalTest.jsx" out of the ESTK and closing the file without saving.

               

              @stephen0218 – changing "globalVar" to "g_globalVar" in my case did not prevent the crash!

               

              @Marc – just tested your line of code on my German InDesign CS5.5. I tested with the ESTK and InDesign, only.

               

              1. Closing the file with cmd + w
              2. Using its menu equivalent
              3. Closing by ticking the x in front of the file name

               

              No crash occured if choosing to close the file without saving.

               

              I have some start-up scripts running not related to bduffy's script.
              To see if they prevent InDesign from crashing I removed them and rerun the tests.
              Same result. No crash…

               

              Also: no problems with your line of code in  InDesign CS5.

               

              Uwe

               

              Message was edited by: Laubender

               

              Message was edited by: Laubender

              • 4. Re: error explanation
                Marc Autret Level 4

                Hi Uwe,

                 

                > I tested with the ESTK and InDesign, only.

                 

                With ESTK all is fine to me too. (Note: ESTK has its own workspace, document manager etc, so it surely interacts with InDesign's active document.)

                I suggest you make the test without ESTK.

                 

                @+

                Marc

                • 5. Re: error explanation
                  bduffy323 Level 1

                  Thank you everyone for your time to recreate this error! Marc's tentative solution seems to do the trick so I will go in and add this to my scripts. Is this something that I should submit as a bug to adobe or is it known bug on their end as well?

                  • 6. Re: error explanation
                    Laubender Adobe Community Professional & MVP

                    @Marc – I got no error with your line of code…
                    With or without using the ESTK.

                     

                    Uwe