ROOT 6 GUI Application is hanging after 40 seconds

Hi ROOT-Experts,

I have a peculiar problem with a ROOT 6.06/02 installation on a Mac OS X El Capitan (installed via homebrew). The application is used a simulator to generate some ZeroMQ Ethernet packets and has some widgets to control the frequency of the packets and so on (no drawing of any Canvases just Buttons and Entries). The actual sending is happening in a separate thread to the main GUI thread and if the application does not have focus, the sending thread hangs after around 40 seconds. If it gets focus back (and i think it has to be visible as well), the sending thread unfreezes and just continues. I experimented with a TTimer and StopIdleing() and RemoveIdleing() methods of the TApplication but had no success. I attached the code as well. I’m grateful for any hints!
Simulator.cc (2.07 KB)
SimulatorViewer.cc (6.13 KB)
Simulator.h (2.48 KB)
SimulatorViewer.h (2.09 KB)
UCTSSimulator.cc (1.79 KB)

Hi,

We’ll take a look and let you know.
BTW, I suspect a Mac OS specific issue. Would you have a chance to test on another OS?

Cheers, Bertrand.

Thanks a lot, will try on a Sl7 machine as well!

BTW, we cannot compile/run the code you sent (missing dependencies) and there is not much I can do by just looking at the code…

I can confirm that it works without problem on an SL7 machine

I attached a tar.bz2 file with all the code, it has a few dependencies… you will need cmake, boost, zmq and protobuf…
CDTS.tar.bz2 (179 KB)

Thanks. We’ll see what we can do.

Cheers, Bertrand.

Thank you :slight_smile:

Hi,

FYI, it will take some time, since I don’t have a Mac and I can only remotely connect to one on which I can’t install system tools (I can only build everything from source in a self-contained directory, to not mess-up the system)… And now I just see that I can’t build protobuf (missing tools). So I’ll have to find another way of testing your code. I’ll keep you in touch.

EDIT: Could you reduce the code to a minimal reproducer I could use without all those dependencies?

Cheers, Bertrand.

Hi Bertrand,
I will provide you with a minimal version.
Cheers
Arnim

Hi Arnim,

Very good, thanks!

Cheers, Bertrand.

Hi Bertrand,

see the example below. It turns out it doesn’t hang but the execution time is slowed down to something like once per two seconds…

#include <unistd.h>

#include <iostream>
#include <thread>

#include <TApplication.h>
#include <TGFrame.h>
#include <TGLabel.h>

struct Doer : public TGVerticalFrame {
  Doer() : counter(0) {}

  void Do() {
    for (;;) {
      std::cout << counter++ << std::endl;
      usleep(500000);
    }
  }
  uint64_t counter;
};

struct SubFrame : public TGVerticalFrame {
  SubFrame(const TGWindow& pParent) : TGVerticalFrame(&pParent, 50, 50), label(this, "buh"), doer(), thread() {
    AddFrame(&label);
    thread = std::thread(&Doer::Do, &doer);
  }

  TGLabel label;
  Doer doer;
  std::thread thread;
};

struct Frame : public TGMainFrame {
  Frame() : TGMainFrame(gClient->GetDefaultRoot(), 100, 100), label(this, "Tester"), subFrame(*this) {
    AddFrame(&label);
    AddFrame(&subFrame);
    SetWindowName("Tester");
    MapSubwindows();
    Resize(GetDefaultSize());
    MapWindow();
  }

  TGLabel label;
  SubFrame subFrame;
};

int main(int, char* argv[]) {
  int fargc = 1;
  TApplication app("Tester", &fargc, argv);

  Frame frame;
  app.Run(kTRUE);
  return 0;
}

Good luck!
Cheers Arnim

Hi Arnim,

Thanks. It seems to work just fine on 10.9.5. I’ll try to find a “El Capitan” one and I’ll let you know.

Cheers, Bertrand.

You’re right, there is something weird (even on 10.9.5). We will investigate…

Cheers, Bertrand.

Okay, glad I’m not going mad :wink:

Hi,

Bertrand and I just tried on my Mac the little test example you provided.
We can see the slow down after roughly 99 iterations. That’s with the cocoa version of ROOT.

We tried also with the X11 version of ROOT and then it works… no slow down.

We found that the “App Nap” feature of Mac is responsible of that. It can be disabled doing:

$ defaults write -g NSAppSleepDisabled -bool true

Ah interesting, thanks for the heads up :slight_smile:
Cheers
Arnim