05-13-2013 01:25 PM - edited 05-13-2013 01:30 PM
I have a strange problem with my app:
The app runs the main UI thread, as well as 4 additional background threads (network I/O operations)
When I compile and run throught the IDE using USB cable, those threads are working without any problems.
When I create a BAR package using the same code, deploy and run it, those threads get suspended if I put the app in background (say after 30 seconds).
I've read about Neutrino's scheduling and thread priorities and then I set all my four threads to have the maximum possible thread priority allowed for a non-root process (63), i.e. for each of them I specify at the beginning:
but the problem still persists.
The threads are suspended if the app is deployed as a release BAR and its window is in background.
The threads are running ok if the app is in foreground/thumbnails _OR_ simply ran from the IDE (in that case, even in background mode the threads are running).
Probably, increasing the threads prio to above 63 will solve the issue, but that would require root permissions and this is not a valid option for our company.
Anyone that has a clue about how I can achive a non-suspendable threads without root permission, please give me a hint
EDIT: Forgot to mention, if I bring back the app from backgrounded to foregrounded state, the threads are neatly resuming and everything runs again flawlessly - therefore this is probably not a deadlock issue
05-13-2013 04:03 PM
Thank you so much, Innovatology, for this hint! That was indeed the problem..... ..........
Now everything works, EXCEPT this
I am reading the accelerometer in a background thread like this:
const QAccelerometerReading* ar = accelerometer.reading(); qreal dx = ar->x(); qreal dy = ar->y(); qreal dz = ar->z();
when backgrounded, I always get dx = dy = dz = 0 regardless that I am shaking the device quite much.
Is it the problem with the accelerometer this time?
05-17-2013 09:21 PM
05-18-2013 02:42 PM
Running in the background By default, an application stops receiving sensor readings once an application is running in the background or the screen is locked. However, it's possible to override this behavior by using the QSensor::alwaysOn property. When set to true, the sensor will continue to send reading updates to the application, even if the application is inactive. In order to use this property, the run_when_backgrounded setting must be enabled in the application's bar-descriptor.xml file.
To conserve battery power, the sensor can be automatically disabled when the device is in standby mode. However, if there is a need to receive sensor events when the screen is off, you can call sensor_set_background() with enable set to true. However, it is important to consider power consumption when using background mode, as it does use additional battery power.