Skip navigation
Currently Being Moderated

Issues with Javascript on Mac but not PC

Jun 29, 2012 11:38 AM

I'm running into some strange issues with some script in which another user's Mac will halt on a line that does nothing more than store a history state to the variable "actHist" while PCs run the entire script fine.  We'll be testing the script an another Mac later today, but I was wondering if there are known issues with running Java based scripts on Macs vs PCs?  Below is a screenshot of the problem:

MacError.png

I can't figure out WHY it stops on that area.  I tried asigning the variable outside the else statement cause I was out of ideas, but it does the same thing regardless where I declare it.  The odd part is, that same line is used elsewhere in the script without issues, it just does not seem to work in this one spot on a Mac (PC has no issues with it).  Any idea why this is only a problem for the Mac and not any PCs?

 
Replies
  • Currently Being Moderated
    Jun 29, 2012 1:42 PM   in reply to dgolberg

    Are your documents in tabbed mode? Preferences->Interface->Open Documents as Tabs on vs off. I think we have issues with scripting when *not* in tabbed mode.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 29, 2012 2:17 PM   in reply to Tom Ruark

    Tom is right. This is a known problem and Adobe has been alerted about it. This error can also occur when trying to access a document's activeLayer.

     

    I've used this code for troublesome lines like this and it has worked for me:

     

    try {
       doc = app.activeDocument;
    } catch  (e) {
       $.sleep(500);
       var desc = new ActionDescriptor();
       desc.putEnumerated(cTID("Stte"), cTID("Stte"), cTID("RdCm"));
       executeAction(cTID("Wait"), desc, DialogModes.NO);
     
       doc = app.activeDocument;
    }
    

     

     

    This has not worked for others. Someone has suggested using:

     

       try {
          doc =  app.activeDocument;
     
       } catch (e) {  
          app.refresh();
          doc =  app.activeDocument;
       }
    

     

    I haven't tried this because I don't have a reproducible test case.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 29, 2012 2:40 PM   in reply to xbytor2

    The above workarounds don't work for me on Windows, the only thing that has worked for me is to set the prefs to tabbed whilst the script is running.

     

     

    function tabInterface(onOff) {
    if(onOff == undefined) onOff=true;
        var desc19 = new ActionDescriptor();
            var ref8 = new ActionReference();
            ref8.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('interfacePrefs') );
            ref8.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
        desc19.putReference( charIDToTypeID('null'), ref8 );
            var desc20 = new ActionDescriptor();
            desc20.putBoolean( charIDToTypeID('EGst'), true );
            desc20.putBoolean( stringIDToTypeID('openNewDocsAsTabs'), onOff );
        desc19.putObject( charIDToTypeID('T   '), stringIDToTypeID('interfacePrefs'), desc20 );
        executeAction( charIDToTypeID('setd'), desc19, DialogModes.NO );
    };
    function isTabInterface(){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    return executeActionGet(ref).getObjectValue(stringIDToTypeID('interfacePrefs')).getBoolean(stringIDToTypeID( 'openNewDocsAsTabs'));
    };
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 1:50 AM   in reply to dgolberg

    I would be interested if anyone could confirm that Macs have problems with running un-tabbed? So far the only confirmed cases I know of have been windows machines. So far a reset of the preferences on a Mac seem to clear their problems.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 2:50 AM   in reply to Paul Riggott

    I work un-tabbed in Photoshop CS6 on a Mac 10.6.8 and have not noticed issues about that yet.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 12:43 PM   in reply to dgolberg

    Have you asked them to reset the preferences?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 3:57 PM   in reply to dgolberg

    It still baffles me as to why it dislikes that line when the exact same line is used elsewhere in the script.

     

    It appears to be a concurrency problem inside PS. The fact that the $.sleep()/waitForRedraw trick works kind of indicates this.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 3, 2012 5:14 AM   in reply to dgolberg

    the app.refresh(); solved the problem!

     

    Thanks much for reporting back on this.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 12, 2013 2:00 AM   in reply to xbytor2

    I've been reported that this issue has been eventually fixed in 13.0.4 (CS6 perpetual product) and 13.1.2 (CS6 creative cloud).

     

    Davide

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points