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

Web and WebWorks Development

Reply
Contributor
Posts: 11
Registered: ‎12-14-2011
My Device: 9370
My Carrier: Verizon

Orientation change breaks app and video gets messed up

I have been writing what I think should be a very simple app, one step beyond Hello World, and am running into some serious problems.

 

The app is a battery monitor, and all it does is registers for a system callback onBatteryLevelChange() when the battery level changes.  When the values change, I use the Flotr Javascript Plotting Library to make a graph.  Here's what it looks like when things are working as expected: 

As long as I leave it in landscape orientation, it will run successfully for the day.  But after a few cycles (landscape -> portrait -> landscape -> portrait -> landscape)  the app breaks and the video becomes unusable.

 

1.  Frequently after an orientation change, the code appears to stop receiving the system callback.  I notice that my app is stuck at an old value while the battery icon in the top system menu indicates a different value.

 

2. Other times the next time the library draws to the screen, the video gets completely messed up, as in the following screen shot:

 

I'm not even sure what to ask.  For such a simple app I would just expect orientation changes to just work.

 

How would one approach identifying the problem?

 


Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Orientation change breaks app and video gets messed up

Hi smccarthy,

 

I would test the same app without the 3rd party library. Perhaps just showing the battery percentage and see if you still run into the stale data issue. My guess is that something in the library is killing javascript processing.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Contributor
Posts: 11
Registered: ‎12-14-2011
My Device: 9370
My Carrier: Verizon

Re: Orientation change breaks app and video gets messed up

I ditched the 3rd party library and simplified down to a text field and an HTML5 <meter> control, but no luck.  App still conks out when orientation changes, and video gets corrupted shortly afterward.

<p>Battery Level <input type="text" id="batteryLevel" value="-2" size="3" maxlength="3">
<meter id="batteryMeter" max="100" value="0"> <p/>

 

From information gleaned from these forums, I am detecting orientation change in Javascript via:

window.onorientationchange = function () {

    alert('new orientation is...' + window.orientation);

    ...

}

 

What's odd is that the code appears to run well in the VMWare simulator running 1.0.7.2942.  The alert()s I have in the onorientationchange() function fire as expected, and app behaves more or less as expected.

 

 When I run it on a real device - I have a 2.x build - the alerts don't get called, and there is no indication that the onorientationchange() callback ever gets called.  It's almost like something has failed at a lower level and so all activity at the higher level just stops.