Having spent some hours of testing and debugging, I consider the problem described here as a BUG.
I condensed the code into a small demo; could anyone please try to verify/confirm?
Technology: MIDP 2.0 lcdui
Reported against: Nokia S60 3rd Edition FP2 (Emulator)
Subject: Midlet gets deadlocked during screen layout
Detailed description: If you put more that (about) 22-24 CustomItems on a form, the midlet will hang up in the call of Display.setCurrent() or Display.setCurrentItem(), i.e. the form will not be displayed. In the debugger, you can see that one thread hangs in Form._setCurrentItem(), another one in CustomItemTest.handleSizeChanged(). For a crosscheck, just comment out about 10 of the append() statements and run the midlet again. Then it'll work.
How to reproduce:
the MIDlet:
Code:
package main;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class MidletTest extends MIDlet
{
public void startApp()
{
FormTest frmTest = new FormTest(Display.getDisplay(this));
frmTest.open(1);
}
public void destroyApp(boolean b)
{
}
/**
* Pausing is not supported in NOKIA's Series 40 and 60 MIDP implementations.
*/
public void pauseApp()
{
}
public void quit() {
notifyDestroyed();
}
}
the Form:
Code:
package main;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import main.CustomItemTest;
public class FormTest extends Form
{
private final Display display;
private final CustomItemTest item00;
private final CustomItemTest item01;
private final CustomItemTest item02;
private final CustomItemTest item03;
private final CustomItemTest item04;
private final CustomItemTest item05;
private final CustomItemTest item06;
private final CustomItemTest item07;
private final CustomItemTest item08;
private final CustomItemTest item09;
private final CustomItemTest item10;
private final CustomItemTest item11;
private final CustomItemTest item12;
private final CustomItemTest item13;
private final CustomItemTest item14;
private final CustomItemTest item15;
private final CustomItemTest item16;
private final CustomItemTest item17;
private final CustomItemTest item18;
private final CustomItemTest item19;
private final CustomItemTest item20;
private final CustomItemTest item21;
private final CustomItemTest item22;
private final CustomItemTest item23;
private final CustomItemTest item24;
private final CustomItemTest item25;
private final CustomItemTest item26;
private final CustomItemTest item27;
private final CustomItemTest item28;
private final CustomItemTest item29;
public FormTest(Display pDisplay)
{
super("test screen");
this.display = pDisplay;
this.item00 = new CustomItemTest();
this.item01 = new CustomItemTest();
this.item02 = new CustomItemTest();
this.item03 = new CustomItemTest();
this.item04 = new CustomItemTest();
this.item05 = new CustomItemTest();
this.item06 = new CustomItemTest();
this.item07 = new CustomItemTest();
this.item08 = new CustomItemTest();
this.item09 = new CustomItemTest();
this.item10 = new CustomItemTest();
this.item11 = new CustomItemTest();
this.item12 = new CustomItemTest();
this.item13 = new CustomItemTest();
this.item14 = new CustomItemTest();
this.item15 = new CustomItemTest();
this.item16 = new CustomItemTest();
this.item17 = new CustomItemTest();
this.item18 = new CustomItemTest();
this.item19 = new CustomItemTest();
this.item20 = new CustomItemTest();
this.item21 = new CustomItemTest();
this.item22 = new CustomItemTest();
this.item23 = new CustomItemTest();
this.item24 = new CustomItemTest();
this.item25 = new CustomItemTest();
this.item26 = new CustomItemTest();
this.item27 = new CustomItemTest();
this.item28 = new CustomItemTest();
this.item29 = new CustomItemTest();
append(this.item00);
append(this.item01);
append(this.item02);
append(this.item03);
append(this.item04);
append(this.item05);
append(this.item06);
append(this.item07);
append(this.item08);
append(this.item09);
append(this.item10);
append(this.item11);
append(this.item12);
append(this.item13);
append(this.item14);
append(this.item15);
append(this.item16);
append(this.item17);
append(this.item18);
append(this.item19);
append(this.item20);
append(this.item21);
append(this.item22);
append(this.item23);
append(this.item24);
append(this.item25);
append(this.item26);
append(this.item27);
append(this.item28);
append(this.item29);
}
public void open(int pFocus) {
display.setCurrentItem(get(pFocus));
}
}
the CustomItem:
Code:
package main;
import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.Graphics;
public class CustomItemTest extends CustomItem {
public CustomItemTest() {
super("");
}
protected void paint(Graphics pGraphics, int pWidth, int pHeight) {
pGraphics.setColor(0x00ffffaa);
pGraphics.fillRect(1, 1, pWidth - 2, pHeight - 2);
pGraphics.setColor(0x00000000);
pGraphics.drawString("TEST", 0, 0, Graphics.TOP | Graphics.LEFT);
}
protected int getMinContentHeight() {
return 20;
}
protected int getMinContentWidth() {
return 40;
}
protected int getPrefContentHeight(int arg0) {
return 20;
}
protected int getPrefContentWidth(int arg0) {
return 40;
}
}
Regards
JS