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
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1

problems debugging a problem

hey guys,

 

I have an issue with my app in which it spikes CPU and it stays high until I restart the app.  the problem is somewhat intermittent and not easy to reproduce.  it doesn't seem to be tied to any particular event that i can zero in on.  I've been able to get profiling to work (after much frustration!) and nothing jumps out.  there's no functions or methods being called excessively.  no memory leaks that i can see.

 

I'm just really having a hard time figuring out how to troubleshoot this at this point.  I'd even consider $$ for someone to help me.

 

is there any vehicle for getting some personal help with this?  I'm pretty competent, but also fairly new to C++ and debugging, and since this problem is hard to reproduce, that makes it even harder.

 

does anyone have any suggestions on what do to?

 

I can run the app in Profile mode (but i've found that the prof.ptrace file isn't all that useful).  i can keep my phone connected and run in debug, i'm just not sure what else to look for.  the app log doesn't show anything useful, it all seems to run normally.  I just can't find what it's doing that is using so much CPU.

 

I'm getting desperate and I don't know what to try next.

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: problems debugging a problem

If you have managed to capture a profile at the time the CPU spikes I'm not sure why you wouldn't be able to see this in the profiling information.

 

The other explanation, and one only someone who is familiar with how the multitasking and resource management works in QNX would really be able to answer, is that your app is asking for a resource that either takes a long time to release or itself takes a lot of CPU cycles.

 

Does anything like that strike a chord with your app?

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: problems debugging a problem

Hi,

 

I'd try logging entry and exit to all of your functions to try get a handle on what is happening.

 

Thanks.

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: problems debugging a problem

As another suggestion I'm not sure if you are familar with the technique called black box testing but removing your class, custom controls, etc. and placing them one by one in their own seperate app is a good way to find out where the fault lies.

 

I use this myself to stress test my custom controls but it's equally as good hunting down where the CPU cycles are being eaten.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1

Re: problems debugging a problem

I had logging at entry and exit of every function. Even had a timer and was timing execution time of each. Then I slowly started undoing that for the simple ones . The functions themselves all run quickly, single digit and low double digits ms. They all seem to complete, that is, they all start and end. Nothing appears to be stuck in a loop. I even added some safety nets to some of the loops in the form of a simple int counter that will break out of the loop if it increments too high, and I can find no evidence that this is happening anywhere.

@bbsjdev, I have profiling info, but I can see anything that looks like a problem.

I will see if I can wrap my head around the "black box" testing. This problem is driving me nutty.
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1

Re: problems debugging a problem

Another quick note... when I have a lot of debug statements, especially with time stamps, the profiler and debugger spend so much time writing output that I have a hard time seeing through the noise.

Any tips on how to do that better?
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: problems debugging a problem

I've used a delta, instead of a timestamp... Number of ms since last log entry... can make it more sortable...

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: problems debugging a problem

If it's possible to reproduce this when the debugger is running, hit the pause button to inspect current state of threads, it might give hints about which function is causing the slowdown.

Also, if there are calls to connect() in QML I'd check all of them are properly disconnected. This isn't done automatically and can sometimes go unnoticed. The slots will be runned multiple times which will eventually cause slowdown.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1

Re: problems debugging a problem

@zmey, that's an interesting lead. What would happen if I connect some signals and slots between a QThread (in c++) and a custom object and that QThread is destroyed (either is told to quit() or or just runs it's course and exits)? Are there "half open" connections that linger?
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: problems debugging a problem

[ Edited ]

You should have something deleting on closure of the thread similar to...

 

	connectResult = connect(mWorker, SIGNAL(finished()), mThread, SLOT(quit()));

	connectResult = connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater()));

However if you have additional signals set up you should disconnect them within these slots with an extended clean up function.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.