7 Replies Latest reply on Jun 23, 2017 1:12 PM by Naoki-Hada

    [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?

    Naoki-Hada Level 1

      I'm not sure what's going on the detail, but it seems only on Mac with Illustrator CC 2017. Windows seems fine.

       

      Currently my code is monitoring what object selected and significant performance issue on certain case.

      I got workaround to work, but I'd like to know if there's better solution.

       

      It is from CEP plugin JavaScript file and used CSInterface.evalScript() to call JSX.

      JSX part is simple and only accessing followings:

           documents.length

           activeDocument.selection.length and typename

       

      On Windows (i7 2.5GHz machine), it responds about 9 - 15 ms.

      On Mac (i7 2.5GHz machine), it responds 20-40 ms. It's obviously slower than Windows.

       

      But if I left for over 50 sec, it responds 2 - 30 second (not millisecond) on Mac.

      Illustrator is foreground.

      Second request become fast as usual.

       

      My current workaround is ping above function every 10 second and avoid Illustrator forget the selection.

      I tried ping with app.version instead of above selection code, so I think it's not CEP or app object part.

       

      Is there any better solution?

       

      Thank you,

      Naoki

        • 1. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
          Ten A Adobe Community Professional

          It's funny, I never seen such case.

           

          Here is a sample code of get notifications from plugins

          ...
          var csInterface = new CSInterface();
          csInterface.addEventListener("com.custom.csxs.events.selectionChanged", function(payload){
            alert(payload.data);
            });
          ...
          

           

          Some my hybrid extensions have similler conponents and almost work fine in my Mac.

           

          Can you show me more detail?

          1 person found this helpful
          • 2. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
            Trevorׅ Adobe Community Professional

            It sounds like Illustrator might be going to sleep in the same way that the ESTK can.

            There's a well know terminal command to stop it doing that.

            The fix at the end of Re: ID CC 2014 plus ExtendScript (Yosemite) slow to the point of not working...  might solve the problem.

            Also there's grefel's fix there.

            Might work, might not. Please get back with the result.

             

            HTH

             

            Trevor

            1 person found this helpful
            • 3. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
              Naoki-Hada Level 1

              Trevor,

               

              Thank you very much for the pointer.

              It looks like one or multiple app or service got into the issue.

              The problem code is for targeting end user environment, so I cannot take the solution.

              It seems similar code works fine on Photoshop and InDesign on Mac though.

               

              Thank you,

              Naoki

              1 person found this helpful
              • 4. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
                Naoki-Hada Level 1

                Ten A

                 

                Thank you very much for the tips.

                Is your hybrid extensions event from Plugin SDK (C++) or Extention Builder (ActionScript)?

                I probably have to do same way.

                 

                Following is the current code and need to improve.

                 

                CEP JS is calling JSX with evalScript().

                1) It is polling every 100 ms in certain state when Illustrator is in foreground.

                2) Other time is every 10 sec in foreground mode.

                3) It was polling every 10 sec when Illustrator is in background.

                It has flag to avoid duplicate request.

                 

                a) JSX part execution time is 120 - 180 micro second on i7 2.5GHz Mac.

                b) CEP JS / JSX part has a lot of over head and responding 20 - 50 ms in most of the case.

                 

                The issue happens after 30-40 sec (50 sec is for sure),

                above b) response become 2 sec to 30 sec (not miliseconds).

                 

                Then it does not recover and Illustrator does not respond in regular timing via CEP JS/JSX.

                Regular operation on Illustrator UI seems fine though.

                 

                The only way to recover I far as I know is call $.gc() from ExtendScript Tool Kit.

                Restarting Illustrator does not help.

                 

                I think it might be related garbage collector, but not really sure.

                 

                So I put $.gc() in following jsxFunc() part. It seems helped some case.

                But it still get into unresponsive state.

                 

                I appreciate any suggestions.

                 

                Thank you,

                Naoki

                 

                 

                CEP / JavaScript

                console.time("polling"); // performance measurement (NodeJs)

                adobe_iface.evalScript("jsxFunc()", function (response) {

                    console.timeEnd("polling"); // performance measurement (NodeJs)

                    // other tasks

                }

                 

                 

                JSX

                function jsxFunc(){

                    $.hiresTimer; // reset

                    $.gc(); // Garbage collector

                    var result = "Unsupported";

                    try{

                        if(documents.length){

                            var _sel = activeDocument.selection; // TextRange when Text chars are selected

                            if("TextRange" == _sel.typename){ // Text char selected

                                var _target = _sel;

                                result = "TextRange";

                            }else if(0 != _sel.length){ // Array: Single and Multiple items case

                                for(var i=0; i<_sel.length; i++){

                                    if(i == 0){

                                        result = _sel[i].typename;

                                    }else{

                                        if(result != _sel[i].typename){

                                            //$.writeln("Got Mixed"); // debug only

                                            result = "Mixed";

                                            break;

                                        }

                                    }

                                }

                            }else{ // No selection

                                result = "NoSelection";

                            }

                        }else{

                            // no doc opened

                        }

                    }catch(e){

                        $.writeln("EXCEPTION: ", e);

                    }

                    $.writeln("jsxFunc: result = ", result, " ", $.hiresTimer, " \xB5s"); // micro second

                    return result;

                }

                 

                Recovery code / JSX

                #target illustrator

                $.hiresTimer; // reset

                $.gc();

                $.writeln("GC done: time = ", $.hiresTimer, " \xB5s"); // micro second

                • 5. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
                  Ten A Adobe Community Professional

                  I understand your solution. Probably, There are some complication problems in background and its difficult to clearly all thing.

                  However, Most easy way to monitoring selection targets is using kAIArtSelectionChangedNotifier in native object.

                   

                  Here is a demo movie.

                  https://www.youtube.com/watch?v=jmqbrARzwME

                   

                  In this case, The plugin is monitoring what objects selected and if selection changed the plugin notify messege to CEP extension.

                  1 person found this helpful
                  • 6. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
                    Naoki-Hada Level 1

                    Ten A

                    Thank you very much for the video and the pointer.

                    Your following article was also very helpful.

                      notifierの設定 - 手抜きLab@DTPの現場

                     

                    I could manage to update MarkedObjectsUI sample code from CC 2017 SDK package

                    and monitor selection change event in CEP's JavaScript code.

                     

                    Thank you very much,

                    Naoki

                    • 7. Re: [Q] Illustrator seems forgeting what selected after 50 sec on Mac. How to avoid?
                      Naoki-Hada Level 1

                      I revisited this solution for disabling App Nap on Illustrator only.

                       

                      Following seems working from short term testing and did not show any slowness..

                       

                      That is command to run in Terminal.

                      After done, Illustrator need to restart.

                       

                      Turn off App Nap for Illustrator (not default setting)

                      ====

                      defaults write com.adobe.illustrator NSAppSleepDisabled -bool true

                      ====

                       

                      Resume default: App Nap for Illustrator

                      ====

                      defaults write com.adobe.illustrator NSAppSleepDisabled -bool false

                      ====

                       

                      Thank you,

                      Naoki