Welcome!

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

Reply
abx
Contributor
Posts: 26
Registered: ‎10-03-2012
My Device: Playbook
My Carrier: lebara

Standby on BB10 dev alpha

When i put my app to thumbnail and then load another app or press standby via power button, I expect, from the docs to have my app be suspended.  Yet, I notice my app is still producing file log tracing, i.e. it's still running.  My app has two threads, one for log tracing and one event handler.   Is this preventing my app from being suspended by the system...

 

I was under the impression that my app's process and hence all its constituent threads would not be preempted by the scheduler and have no cpu slice afforded to it.   Yet, I see trace being produced, even though run_when_backgrounded is not set in my descriptor.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Standby on BB10 dev alpha

I see basically the same behaviour, and have theorized for the moment that without "run_when_backgrounded" set, threads which do not interact with the bps event loop (for example) are unaffected, at least for now. I even wrote a test thread which simply entered an infinite loop, and sure enough the app sucked up most of the CPU even while the app was minimized.

I believe for now, at least, native apps will need to handle this manually. Monitor the thumbnail and/or related signals in your main thread and adjust your overall app state to prevent "free-running" secondary threads from continuing to use CPU.

I haven't seen any detailed documentation that covers this yet.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
abx
Contributor
Posts: 26
Registered: ‎10-03-2012
My Device: Playbook
My Carrier: lebara

Re: Standby on BB10 dev alpha

I've adjusted my code to suspend all secondary threads on thumbnail, inactive and invisible events.  My only issue now seems to be a race condition ...  Some of my secondary threads interact with the main thread via user events but the system seems to have suspended the main thread before I can even push the user event onto the main thread's active channel.  

 

I wish the docs made it explicit on what happens on standby and when and to what threads.

Highlighted
Developer
Posts: 1,626
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Standby on BB10 dev alpha

Isn't the Active Frame like Application Bahavior == ShowCase on the Playbook where it continues to run in the background?