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

Java Development

Reply
New Developer
roryf
Posts: 24
Registered: ‎07-23-2008
My Device: Not Specified

App 'freezes' after opening menu

Hi,

 

I have a user of our application claiming that it 'freezes' sometimes, and the only way to fix is a soft reset. I had the user look in the event log for an exception, since the app catches all unhandled exceptions using catch(Throwable) to print the stack trace, and they found the following:

 

Name: RuntimeException
GUID: 9c3cd62e3320b498
Time: Jan 28, 2009 00:51:41
pushModalScreen called by a non-event thread
net_rim_cldc-8
 UiEngineImpl
 pushModalScreen
 0xA3DC
net_rim_cldc-6
 Menu
 show
 0xBC87
net_rim_cldc-8
 Screen
 onMenu
 0x547D
net_rim_cldc-8
 Screen
 keyCharUnhandled
 0x5240
net_rim_cldc-8
 Screen
 dispatchKeyEvent
 0x4682
net_rim_cldc-2
 MIDPScreen
 dispatchKeyEvent
 0x99B6
net_rim_cldc-8
 Screen
 processKeyEvent
 0x6691
net_rim_cldc-8
 UiEngineImpl
 processMessage
 0x99C6
net_rim_cldc-5
 Application
 processNextMessage
 0x1392
net_rim_cldc-5
 Application
 enterEventDispatcher
 0xA51
net_rim_cldc-3
 MIDletMain
 main
 0x51C8 

 

My app is a MIDlet application so can't be calling pushModalScreen, and looking at the stack trace it shows the exception occurring when the platform tries to show the menu. The user is on an 8310 and I had them upgrade to the latest OS, they are now on 4.5.0.124 and the platform is 2.7.0.92 (I think they meant .174, I don't see a .124 build).

 

Any ideas what could be the cause here? Is this a known issue? could my app be causing it somehow?

 

Thanks for any help,

Rory

Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: App 'freezes' after opening menu

Even though your have created a MIDlet, under the covers there is still the concept of a main event thread.  It looks like a screen update is being attempted outside of the main event thread.  Do you know what area of your application is triggering this?  Can you post a code sample that reproduces this behaviour?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
roryf
Posts: 24
Registered: ‎07-23-2008
My Device: Not Specified

Re: App 'freezes' after opening menu

Thanks for a response.

 

I don't know what is triggering this. Looking at the stack trace I fail to see how it could be my code, it looks to be the key press handling and I don't have any code that either initiates or listens for key presses.

 

I have various places where my app sets the current Displayable outside of the main event thread and haven't had any issues with it. The docs also state that this is perfectly legal behaviour.

 

Unless I'm missing something (and without any understanding of the inner-workings of the API I could well be), it appears to be occurring when attempting to show the menu. I would expect this to be in response to the menu key being pressed and I'm not aware of any way in which that event could be passed to my app somehow.

 

Is it possible another app is causing the issue, and since mine happens to be open at the time it is the one that experiences the problem?

 

Cheers

Please use plain text.
Developer
simon_hain
Posts: 15,940
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: App 'freezes' after opening menu

the exception is thrown by menu.show.
Do you use the menu class in your application? or any other rim ui class?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
roryf
Posts: 24
Registered: ‎07-23-2008
My Device: Not Specified

Re: App 'freezes' after opening menu

 We don't use any RIM UI classes, only depend on high level LCDUI classes.
Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: App 'freezes' after opening menu

Can you provide the exact steps that trigger this as well as the code that is running?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
roryf
Posts: 24
Registered: ‎07-23-2008
My Device: Not Specified

Re: App 'freezes' after opening menu

We haven't been able to recreate this internally so I don't have any steps, only the customers report and the stack trace they sent in. I still stand by my assumption that it isn't our code causing this, we don't handle or initiate any key events. I also don't see how this could be occurring in one of our application's threads given that the stack trace only shows framework code.
Please use plain text.
New Developer
mcmordie
Posts: 50
Registered: ‎01-22-2009
My Device: Z10
My Carrier: Rogers

Re: App 'freezes' after opening menu

Any progress on this?  I have a tester who experiences this on his 8310, running OS 4.5.  Issue will not duplicate in the 4.5 8310 simulator.
Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: App 'freezes' after opening menu

Can you provide a code sample that is triggering this?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
mcmordie
Posts: 50
Registered: ‎01-22-2009
My Device: Z10
My Carrier: Rogers

Re: App 'freezes' after opening menu

It requires my entire application to duplicate, which for obvious reasons I can't post.  Any attempt to pair down the issue to a smaller set of classes results in an application which doesn't exhibit the behaviour.  Fortunately, I believe I have tracked down and corrected the problem.

 

My application was split into a GUI component, which can be launched, foregrounded, quit, etc, and a background thread which does slow, offline number crunching on a periodic timer.  The application inserted menu items into other BB apps menus to launch the GUI component from certain other apps.  It looks like when the run methods corresponding to these menu items was invoked, it was foregrounding the GUI component without first holding the event lock.  This only caused problems on slower BB models such as the 8100 and 8310, and only on real hardware.  I assume this means that the simulators are not cylce accurate-- they run the same code, but they run it much faster than the real phones.  The problem was never duplicated on the Bold.  Even on the slower phones, the issue sometimes took 30-40 minutes of intensive testing to duplicate.  Very frustrating!

 

What cured the problem was wrapping Application.requestForeground() call in a synchronized( Application.getEventLock() ) {} block.  This was a guess, based on the error messages which were logged on the phones (the same error message the other user posted above).

 

I don't completely understand why the Application.requestForeground() doesn't do the synchronization internally (seems to me this would be a good idea) perhaps there is a reason for this.  I have seen this problem in other applications installed on my BB.  If the application always has the event lock when running, another option would be to make the requestForeground method private.  I was calling it from a separate thread.  Please let me know if this is not the right way to do this!

 

Anyway, I hope this helps someone else out there who falls into the same trap.  The fact that the menu just freezes after the app is brought to the front is a very strange behaviour!

Please use plain text.