Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Headless applications not getting invoked on system startup

[ Edited ]

We have thoroughly investigated this issue on our side and I wanted to share our findings here.


In BlackBerry10, apps that do not get in to the event loop within 6 seconds from the time they are launched gets automatically terminated. That is exactly what is happening in this case. This is why we strongly recommend to use call Application::exec() before doing heavy initializations of your app. Please see how this can be accomplished below:


First, define a Q_INVOKABLE init() function in your main application class

// header file: add q_invokable init() method:
class MyClass : public QObject {
    Q_INVOKABLE void init();


 Invoke the init() function in the constructor of your main application class

MyClass::MyClass() : QObject()
    QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
    // do nothing else than invoking init(), which will do all the heavy work once the event loop has started


In your main(), call the constructor of your main application class and immediately enter the event (exec()) loop

// in cpp files:
int main(int argc, char **argv)
    Application app(argc, argv);
    MyClass c;
    return Application::exec();


That way, the main application class constructor will call the init function as soon as the app enters the event loop and NEVER before entering the event loop. This ensures that the app does not waste any time between the time it gets launched and when it enters the event loop.


Still Not Good Enough

Now that's all good but it still does not guarantee a fix. We can still have issues when several apps are getting launched at the same time especially when the system is very busy during startup. To fix that, we have made some changes on our side so that all apps do not get launched at the same time, instead, the system will launch one third party headless app at a time. This fix has gone in to 10.3 version of the OS. 


10.3 or 10.2.1, you should however, always follow the recommendation above..





Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Headless applications not getting invoked on system startup



thanks for explaining.


...and to see again it's a good practice to do work async using signals/slots

ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Posts: 1,636
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Headless applications not getting invoked on system startup

I have the latest 10.2.1 installed and 5 of 6 headless apps got started.  One is not.  So the problem is still there.


Will test on OS10.3