Menu freezes for Blackberry Port on Storm
I developed an app that so far works on all java and blackberry phones apart from the storm.
On the storm, simply clicking outside the menu when it is open causes a the app to freeze. On the blackberry logs, I get a message about
"Process myapp(219) queue too large (31); user input event(s) dropped"
I fought with this from Dec 7th '11 to Jan 28th '12. After scanning the internet and finding that I was the only one who seemed to have generated this error with LWUIT, I checked blackberry forums and found that throttling events can reduce this problem. So I started messing with everything in my code that had to do with menus. NOTHING. I asked Chen Fishbein, he too did not know why that should happen. So I dived into LWUIT code, and after much tinkering, I discovered that there are many places to tweek, but I finally chose this
//Dialog.java
public void dispose() {
setDisposed(true);
// the dispose parent method might send us back to the form while the command
// within the dialog might be directing us to another form causing a "blip"
// if(menu) { //I removed this block
// }
super.dispose();
}
public void pointerReleased(int x, int y) {
//enter my code
if (menu) {
try {
Thread.sleep(500);//I tried different delays, 500-700 eliminated it almost entirely
} catch (Exception e) {
}
}
//my code ends
super.pointerReleased(x, y);
if(disposeWhenPointerOutOfBounds &&
!getTitleComponent().contains(x, y) &&
!getContentPane().contains(x, y) &&
!getMenuBar().contains(x, y)){
dispose();
}
}
//MenuBar.java
protected Command showMenuDialog(Dialog menu) {
~~~~~~~~~~~~~~~~~~~~~~
some code here
~~~~~~~~~~~~~~~~~~~~~~
} else {
return menu.show(height, 0, marginLeft, marginRight, true, false);// I changed this line to make it modeless
}
}
protected List createCommandList(Vector commands) {
//my code
List l = new List(commands) {//you will notice I customized this List
public void pointerReleased(int x, int y) {
super.pointerReleased(x, y);
dispatchCmd();
}
public void keyReleased(int code) {
int game = Display.getInstance().getGameAction(code);
if (game > 0 && game == Display.GAME_FIRE) {
dispatchCmd();
} else {
super.keyReleased(code);
}
}
public void dispatchCmd() {
Command c = getComponentSelectedCommand(this);
if (!c.isEnabled()) {
return;
}
getComponentForm().dispose();
parent.dispatchCommand(c, new ActionEvent(c));
}
};
//my code ends
l.setUIID("CommandList");
Component c = (Component) l.getRenderer();
c.setUIID("Command");
c = l.getRenderer().getListFocusComponent(l);
c.setUIID("CommandFocus");
l.setFixedSelection(List.FIXED_NONE_CYCLIC);
if(UIManager.getInstance().isThemeConstant("menuPrefSizeBool", false)) {
// an entry way down in the list might be noticeably wider
l.setListSizeCalculationSampleCount(50);
}
return l;
}
I do wish I could know what caused it though so I don't have to do all this tweeking




