19 Replies Latest reply on Jul 19, 2016 6:41 AM by JThoeming

    Progress Bar bug. Summary of the situation

    TᴀW Adobe Community Professional & MVP

      I've done a good amount of testing on Windows and Mac, and here's a report of where the progress bar bug bites. (The bug is that the progress bar doesn't progress; well, it doesn't appear altogether. Also this bug isn't really limited to the progress bar: in every case of a modeless window [a "palette" window], nothing refreshes while the script is being run, as per the table below.)

       

      Interestingly, it makes a difference whether the script is run from the Scripts panel or via a script menu action. And of course, because the ScriptUI engine changed between CS6 and CC, that makes a big difference as well (at least on Windows).

       

      1. Mac OS (Yosemite)

      InDesign CS6InDesign 2015
      Redraw OnRedraw OffRedraw OnRedraw Off
      1. Run from panelXX
      2. Run from menuXXXX

       

      2. Windows 7

      InDesign CS6InDesign 2015
      Redraw OnRedraw OffRedraw OnRedraw Off
      1. Run from panelX
      2. Run from menuXX

       

      Summary:

      1. In InDesign CS6 on Windows, the progress bar always works!

      2. In every other case, the progress bar will only work if the script is run from the scripts panel with redraw on.

       

      There has been at least one other post about this issue here on the forum, but I've tried to systematically test each possibility. Post here if you've noticed different results!

       

      I don't have Windows 10 to test on, but I presume it's the same. Ditto El Capitan.

       

      If anyone knows of a workaround, please share it here!

       

      Ariel

        • 1. Re: Progress Bar bug. Summary of the situation
          Loic.Aigon Adobe Community Professional

          Hi Ariel,

           

          I used a workaround inspired by Marc Autret's work which consisted in creating a new window instance for every step while closing the underlaying one. That worked well a few versions ago (CS6 or CC). But I recently tried to reuse this trick for a project in a CC14/15 environment and that doesn't work anymore.

          Perhaps Marc or Peter will share some thoughts here.

           

          I don't know what to think of ScriptUI those days and should I say of UIs in general as there are inconsistencies and trouble whatever the ecosystem you try to work with…

           

          Loic

          • 2. Re: Progress Bar bug. Summary of the situation
            TᴀW Adobe Community Professional & MVP

            Hi Loic,

             

            Thanks for chipping in.

            I used a workaround inspired by Marc Autret's work which consisted in creating a new window instance for every step while closing the underlaying one. That worked well a few versions ago (CS6 or CC). But I recently tried to reuse this trick for a project in a CC14/15 environment and that doesn't work anymore.

            I guess it was CC, or maybe CS6 on the Mac. Sounds a bit crazy, but if it worked, why not! I wonder why it doesn't work any more.

             

            ScriptUI is still good for basic stuff, and it's much less hassle than anything else I'm aware of.

             

            Ariel

            • 3. Re: Progress Bar bug. Summary of the situation
              Loic.Aigon Adobe Community Professional

              ScriptUI is still good for basic stuff


              Yeah for sure but all those inconsistencies, really ? Plus the lack of support. Was told ScriptUI is no longer developed nor considered at Adobe.

               

              If Adobe doesn't want to support ScriptUI any longer, why not but what is the alternative ??? The problem is also that as far as I am concerned I have no idea of who at Adobe is in charge of those technologies. That would be nice to have a point with them about this.

               

              Loic

              • 4. Re: Progress Bar bug. Summary of the situation
                TᴀW Adobe Community Professional & MVP

                Hold on! Is the answer as simple as adding a w.update()?!

                 

                The following works for me on Windows and Mac, both as a menu item and run from the scripts panel, on ID 2015.2:

                 

                app.scriptPreferences.enableRedraw = false;
                w = new Window('window', 'Redraw = true');
                pb = w.add('progressbar', [12, 24, 450, 36], 0, 100);
                w.show();
                for (i = 0; i < 100; i++){
                  pb.value = i;
                  w.update();
                  $.sleep(50);
                }
                w.close();
                

                 

                Anyone care to confirm this? It would be fantastic if the answer was this simple!

                 

                Ariel

                1 person found this helpful
                • 5. Re: Progress Bar bug. Summary of the situation
                  Marc Autret Level 4

                  Hi all,

                   

                  There are now many separate threads on the Progress Bar Case so thank you Ariel for opening a central topic. It would be nice to have all tests and reports collected here to avoid dispersion and duplication.

                   

                  My two pennies on this complicate subject.

                   

                  1. Summary.

                  To my knowledge, using both enableRedraw=true and window.update() is the safest way to get a working progress bar in almost all versions and platforms. In most configurations enableRedraw is even not required provided that window.update() is used. [Note about my ProgressBar component: some scripters still refer to an old version of the code that does not include the window.update() trick. So I've updated the jsx on GitHub to avoid any confusion: ProgressBar.jsx (indiscripts/extendscript)]

                   

                  2. Direct call from the Scripts panel.

                  From CS6 to CC2015, the following code should pass the test in Windows (all versions) and Mac OS before El Capitan:

                  const REDRAW = true;
                  const WIN_KIND = 'palette';
                  const SLEEP = 30;
                  
                  // ProgressBar component.
                  // ---
                  $.hasOwnProperty('ProgressBar')||(function(H/*OST*/,S/*ELF*/,I/*NNER*/)
                  {
                      H[S] = function ProgressBar(/*str*/title,/*uint*/width,/*uint*/height)
                      {
                          (60<=(width||0))||(width=340);
                          (40<=(height||0))||(height=60);
                  
                          var H = 22,
                              Y = (3*height-2*H)>>2,
                              W = new Window(WIN_KIND, ' '+title, [0,0,width,height]),
                              P = W.add('progressbar', { x:20, y:height>>2, width:width-40, height:12 }, 0,100),
                              T = W.add('statictext' , { x:0, y:Y, width:width, height:H }),
                              __ = function(a,b){ return localize.apply(null,a.concat(b)) };
                  
                          this.pattern = ['%1'];
                  
                          W.center();
                  
                          // ---
                          // API
                          // ---
                  
                          this.msg = function(/*str*/s,  v)
                          // ---------------------------------
                          {
                              s && (T.location = [(width-T.graphics.measureString(s)[0])>>1, Y]);
                  
                              T.text = s;
                              W.update();
                          };
                  
                          this.show = this.reset = function(/*str*/s, /*uint*/v)
                          // ---------------------------------
                          {
                              if( s && s != localize(s,1,2,3,4,5,6,7,8,9) )
                                  {
                                  this.pattern[0] = s;
                                  s = __(this.pattern, [].slice.call(arguments,2));
                                  }
                              else
                                  {
                                  this.pattern[0] = '%1';
                                  }
                  
                              P.value = 0;
                              P.maxvalue = v||0;
                              P.visible = !!v;
                  
                              this.msg(s);
                  
                              W.show();
                              W.update();
                          };
                  
                          this.hit = function(x)
                          // ---------------------------------
                          {
                              ++P.value;
                              ('undefined' != typeof x) && this.msg(__(this.pattern, [].slice.call(arguments,0)));
                              W.update();
                          };
                  
                          this.hitValue = function(v,x)
                          // ---------------------------------
                          {
                              P.value = v;
                              ('undefined' != typeof x) && this.msg(__(this.pattern, [].slice.call(arguments,1)));
                              W.update();
                          };
                  
                          this.hide = function()
                          // ---------------------------------
                          {
                              W.hide();
                          };
                  
                          this.close = function()
                          // ---------------------------------
                          {
                              W.close();
                          };
                      };
                  
                  })($,{toString:function(){return 'ProgressBar'}},{});
                  
                  
                  app.scriptPreferences.enableRedraw = REDRAW;
                  
                  // Testing simple modeless win + progressbar widget
                  // ---
                  var w = new Window(WIN_KIND, 'Redraw = ' + REDRAW),
                      pb = w.add('progressbar', [12, 24, 450, 36], 0, 100);
                  w.show();
                  for (i = 0; i < 100; i++){
                    pb.value = i;
                    w.update();
                    $.sleep(SLEEP);
                  }
                  w.close();
                  
                  // Testing ProgressBar
                  // ---
                  PB = new $.ProgressBar('ProgressBar',462,60);
                  PB.show("Value = %1",100,0);
                  for (i = 0; i < 100; PB.hit(++i) ){
                    $.sleep(SLEEP);
                  }
                  PB.close();
                  

                   

                  3. But things are broken again on El Capitan!

                  I had the stupid idea to install El Capitan and test the code above from CS6 to CC2015, and boom! Only InDesign CS6 displays the progress bars. The new UI architecture introduced with CC causes the palette to remain invisible, and this is a generic issue, I mean, not specifically related to the progressbar widget. According to my tests InDesign CC + El Capitan don't want to wake up any non-modal window as long as the script is running. More exactly, you need to have a “modal phase” (for example, an alert box) to force the palette to show up. Therefore, there is no way—or at least no obvious way—to implement a progress bar. Neither invoking repeatedly myPalette.update(), nor switching the enableRedraw state, nor mimicking short modal transitions through a dialog that automatically closes on the activate event, nor etc, will solve the issue.

                   

                  Note a. — Interestingly our progress bars seem to work fine when the script is launched from the ESTK engine rather than ID.

                   

                  Note b. — In case you don't close/hide the ScriptUI window, you will notice that the 'palette' type is definitely safer than the 'window' type. Indeed, I observed that InDesign's own workspace may hide a windowed window (so you don't see anything) while it won't hide a palette.

                   

                  4. The MenuAction issue.

                  Finally, we still have a serious problem in making a non-modal UI visible and/or updating its progress bar when the underlying script is executed from a menu item invocation. (Here again this issue is Mac-specific.) I believe we already had discussions on this subject, albeit no definitive workaround has been found.

                   

                  @+

                  Marc

                  • 6. Re: Progress Bar bug. Summary of the situation
                    TᴀW Adobe Community Professional & MVP

                    Thanks Marc.

                     

                    1. You say "in most configurations enableRedraw is not even required provided that window.update() is used." Apart from El Capitan, in what case have you found that window.update() alone does not work?

                     

                    2. It sounds like there is no way to display any modeless ScriptUI dialog in El Capitan, and this is not just limited to progress bars? Or are you talking only about "Window"-type windows, whereas "palette"-type windows are ok?

                     

                    I haven't yet installed El Capitan so I cannot test on that. Also, I haven't installed Windows 10, only Windows 7.

                     

                    But to summarize the situation as far as my tests are able: All the following combinations work fine provided window.update() is used even if enableRedraw is false: InDesign CS6, InDesign 2015.2, on both Windows 7 and Yosemite, whether run from the scripts panel or from a menu.

                     

                    For me, that is a big improvement to the situation in the first post in this thread.

                     

                    Does anyone have Windows 10 up and running that they could test a progress bar there with enableRedraw off and using window.update()?

                     

                    So we are left with El Capitan, which apparently has no solution as of yet.

                    • 7. Re: Progress Bar bug. Summary of the situation
                      Marc Autret Level 4

                      Hi Ariel,

                       

                      TᴀW wrote:

                       

                      1. You say "in most configurations enableRedraw is not even required provided that window.update() is used." Apart from El Capitan, in what case have you found that window.update() alone does not work?

                       

                      Indeed I have no recent case in which enableRedraw is required, but I keep cautious about this because I don't use previous Mac systems anymore (that is, before Yosemite) and I don't remember when and where we had to introduce the enableRedraw condition. Also, I can't test scripts with older ID versions on my Mac. In ScriptUI for Dummies (v2.10, page 64) Peter Kahrel maintains that enableRedraw is needed for progress bars to display correctly. In doubt I cant' totally relax that requirement, that's why I wrote "in most configurations…".

                       

                      Anyway you're absolutely right to emphasize that this is a crucial issue. If we could completely get rid of enableRedraw it would be great in terms of performance for those various scripts that don't need instant redrawing.

                       

                      TᴀW wrote:

                       

                      2. It sounds like there is no way to display any modeless ScriptUI dialog in El Capitan, and this is not just limited to progress bars? Or are you talking only about "Window"-type windows, whereas "palette"-type windows are ok?

                       

                      I was talking about both window and palette types, that is, any non-modal Window instance . I tested both cases.

                       

                      @+

                      Marc

                      • 8. Re: Progress Bar bug. Summary of the situation
                        TᴀW Adobe Community Professional & MVP

                        Marc,

                        Indeed I have no recent case in which enableRedraw is required, but I keep cautious about this because I don't use previous Mac systems anymore (that is, before Yosemite) and I don't remember when and where we had to introduce the enableRedraw condition. Also, I can't test scripts with older ID versions on my Mac. In ScriptUI for Dummies (v2.10, page 64) Peter Kahrel maintains that enableRedraw is needed for progress bars to display correctly. In doubt I cant' totally relax that requirement, that's why I wrote "in most configurations…".

                        Well, in my testing it works without enableRedraw, though that only goes back as far as Yosemite and CS6 and Windows 7. That will have to do for now.

                        I was talking about both window and palette types, that is, any non-modal Window instance . I tested both cases.

                        So no non-modal ScriptUI dialogs in El Capitan with ID2015? I can't believe it! I think I'm in denial...

                         

                        I can't help thinking that Adobe should be testing all the various configurations, and not leaving it up to small 3rd-party developers to discover combinations of operating systems and versions of InDesign that just don't work properly!

                         

                        Ariel

                        • 9. Re: Progress Bar bug. Summary of the situation
                          Marc Autret Level 4

                          TᴀW wrote:

                           

                          So no non-modal ScriptUI dialogs in El Capitan with ID2015? I can't believe it! I think I'm in denial...

                           

                          That's not exactly what I've reported. Non-modal windows don't display “as long as the script is running.” Once the script has terminated, the palette (or the 'window' Window) will show up. You need a modal break to have it displaying. At least this is what I'm observing.

                           

                          @+

                          Marc

                          • 10. Re: Progress Bar bug. Summary of the situation
                            Laubender Adobe Community Professional & MVP

                            Hi Ariel and Marc,

                            justed tested Marc's script from answer #5 with CS6 v8.1.0 and CC v9.3.0 on Mac OSX 10.6.8.

                             

                            Enable redraw true or false. Both cases are working.

                            Started from the ESTK or started from InDesign's Scripts Panel.

                             

                            Cannot test with El Capitan.

                            But will do with CS6, CC and CC 2014.2 on OSX 10.7.5 as well.

                             

                            Uwe

                            • 11. Re: Progress Bar bug. Summary of the situation
                              Laubender Adobe Community Professional & MVP

                              My tests with OSX 10.7.5 went well so far. The progress bar is working.
                              I had one strange occurance after starting CS6 with the welcome screen present—I mean the screen where last used documents are listed.
                              The progress bar apparently ran "behind" the screen. I tried, but I couldn't recreate the behavior. Even after a restart of InDesign.

                               

                              Note: You can stop the progress bar temporarily by using the mouse or the trackpad when holding the mouse key down.
                              Either when the cursor is in the upper area, the title bar of the widget, where you can drag it around or in the area where the moving bar is showing.
                              Not when the cursor is at the moving bar itself or at the field for the updating numbers.

                               

                              Tested with CS6 v8.1.0, CC v9.3.0 and CC 2014.2 on Mac OSX 10.7.5.

                               

                              Uwe

                              • 12. Re: Progress Bar bug. Summary of the situation
                                Loic.Aigon Adobe Community Professional

                                Quick question : isn't it time to get a statement from Adobe regarding to ScriptUI and building interfaces in general ?

                                 

                                I have from an excellent authority that ScriptUI is no longer a concern at Adobe. However we all agree that we still need a solution for interfaced scripts lighter than extensions.  My feeling is that I can't even think of someone at Adobe dedicated to these concerns. A few come and leave. Another few stay but with no (known) project leadership entitlement.

                                 

                                I can imagine none technologies is error free but we should notice constant improvements in a vertuous circle. It's all but it.

                                 

                                I also know we are two few to make enough noise but I think it would be a mark of respect that Adobe concerned services state once and for all their intention. Do they think of stabilizing ScriptUI (which I don't think), do they think of providing another interface solution ?

                                 

                                In one word : what is the road-map and who is in charge !?

                                 

                                Sorry if off-topic or just restating the obvious here.

                                 

                                Loic

                                • 13. Re: Progress Bar bug. Summary of the situation
                                  TᴀW Adobe Community Professional & MVP

                                  @Marc: It's a little difficult for me to understand what you mean, but it sounds like if there's a script that's essentially event-based (things only happen when the user clicks something), it will work okay, if I've understood correctly.

                                   

                                  Ariel

                                  • 14. Re: Progress Bar bug. Summary of the situation
                                    TᴀW Adobe Community Professional & MVP

                                    Thanks Uwe.

                                     

                                    It sounds like using update() works in most cases, then, as Marc said.

                                    • 15. Re: Progress Bar bug. Summary of the situation
                                      TᴀW Adobe Community Professional & MVP

                                      Loic, I agree -- I'll try to send some emails and see if I can get an answer. Not too hopeful.

                                       

                                      Ariel

                                      • 16. Re: Progress Bar bug. Summary of the situation
                                        cbishop01 Level 2

                                        A little FYI.  These were not working on Indesign CC 2015.3 (For me) until the new update to 2015.4 Now both work.

                                        • 17. Re: Progress Bar bug. Summary of the situation
                                          Marc Autret Level 4

                                          cbishop01 a écrit:

                                           

                                          These were not working on Indesign CC 2015.3 (For me) until the new update to 2015.4 Now both work.

                                           

                                          On which OS?

                                          • 18. Re: Progress Bar bug. Summary of the situation
                                            cbishop01 Level 2

                                            Sorry.. THe lateset Mac OSX El Capitan. as of 6-24-2016.  I believe it is 10.11.4.

                                            • 19. Re: Progress Bar bug. Summary of the situation
                                              JThoeming Level 1

                                              The latest Update with OS X 10.11.6 and InDesign CC 2015.4 helped - now the Scripting UI seem to work again as it should.

                                               

                                              The Progress Bar Issue is gone at least ...

                                               

                                              Best regards

                                               

                                              Joerg