# SetBatch causes different graphics output for pngs

**URL:** <https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682>\
**Category:** ROOT\
**Created:** [August 12, 2015, 7:44pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682 "2015-08-12T19:44:25Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 15, 2017, 9:03am UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/21 "2017-09-15T09:03:07Z")

</div>

I ran this “10-times-in-a-row” command several times (\>30) . And I saw that it was not right 2 or 3 times over 300 (10x30). I did the test with ROOT 6 and ROOT 5.34. I did a change in TRootCanvas to improve this (I increased the Sleep time between the 2 ProcessEvents). After this change both ROOT 6 and ROOT 5.34 gave me a 100% success when I ran the “10-times-in-a-row” command 30 times with the X11 backend. I committed this change for both ROOT 6 and ROOT 5.34. I hope that will be 100% success for you also.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 15, 2017, 1:51pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/22 "2017-09-15T13:51:07Z")

</div>

I play with “v5-34-00-patches" only and it seems I was able to “stabilize” it.

The original old source code of “TRootCanvas::SetWindowSize” failed in something like 40% of trials. After adding “gVirtualX-\>Update(1);”, it failed in something like 33% of trials. After “gSystem-\>Sleep(100);” modification, it failed in something like 27% of trials. So I tried “gSystem-\>Sleep(1000);” and it still failed in something like 15% of trials.

So, I decided to play with this myself and I have found a solution which seems to work:

```auto
   gVirtualX->Update(1);
   if (!gThreadXAR) {
      gSystem->Sleep(100); // at least 50; 100 is safer                         
      gSystem->ProcessEvents();
      gSystem->Sleep(10); // does not matter at all                             
      gSystem->ProcessEvents();
   }

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 15, 2017, 2:42pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/23 "2017-09-15T14:42:00Z")

</div>

Thanks for your input. Your X11 server is slower to sync than mine it seems. I verified that this new way of doing it also works for me. It does. I also changed TASImage accordingly for consistency. I committed these change for both ROOT 6 and ROOT 5.34. Thanks for your help in the final tuning.

[Previous page](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682.md?page=1)
