03-20-2012 10:07 AM - edited 03-20-2012 01:48 PM
Hi all,
I am having load time issues with my app that I am writing. The problem is that on a device or emulator, the app will take about 45 seconds to load, but only about 2 of that is loading my app. The rest of the time appears to be things going on in the OS. Please forgive the length of my post, but I'm not sure what is relavant to the solution. If anyone has any insight, that would be amazing.
Here is the debug log. Everything related to my app is in bold.
FocusHistory: Focus gained; App CreativeCore; Component net.creative.core.CreativeCore$AppScreen
BRM:IDL+
BRM
R+
BRM:NMC:25296896
BRM:JFR:52515152
BRM
R-
BRM:NMC:25296896
BRM:JFR:52515040
BRM:IDL-
VM:CMPOv=15
JVM: bklt @1091484: timer
JVM: bklt[1] @1091484: usrIdle 12, usrTime 30, usrAct 1
JVM: bklt[1] @1091484: chkIdle 80, currTime 30
JVM: bklt @1091484: setTimer 18
JVM: bklt @1109476: timer
JVM: bklt[1] @1109476: usrIdle 30, usrTime 30, usrAct 1
JVM: bklt[1] @1109476: chkIdle 98, currTime 30
JVM: bklt[1] @1109476: enableBacklight 0
JVM: bklt[1]: setTimeout 30
JVM: bklt[1] @1116351: JBSC on=0
JVM: bklt[1] @1116351: SC 0
JVM: bklt[1]: setTimeout 30
AM: Starting net_rim_hotspotclient_att
AM: net_rim_hotspotclient_att already running
JVM: bklt[1] @1123132: JBSC on=1
JVM: bklt[1] @1123132: SC 1
JVM: bklt @1123132: setTimer 30
VM:CMPOv=11
VM:+GC(f)w=11
VM:-GCt=132,b=1,r=0,g=f,w=11
VM:QUOT t=6
VM:+CR
VM:-CR t=65
WM(finalizeNativeWindowWrapper) - ref=0x25d10400
WM(finalizeNativeWindowWrapper) - ref=0x25d14000
WM(finalizeNativeWindowWrapper) - ref=0x25d20400
WM(finalizeNativeWindowWrapper) - ref=0x25d25c00
WM(finalizeNativeWindowWrapper) - ref=0x26d28400
WM(finalizeNativeWindowWrapper) - ref=0x26d35000
WM(finalizeNativeWindowWrapper) - ref=0x26d98400
WM(finalizeNativeWindowWrapper) - ref=0x26d9b800
WM(finalizeNativeWindowWrapper) - ref=0x26d9e400
WM(finalizeNativeWindowWrapper) - ref=0x26da1c00
WM(finalizeNativeSyncWrapper) - ref=0x34aefc00
WM(finalizeNativeWindowWrapper) - ref=0x34ae9800
WM(finalizeNativeWindowWrapper) - ref=0x34a04800
WM(finalizeNativeWindowWrapper) - ref=0x34be9c00
WM(finalizeNativeWindowWrapper) - ref=0x34be5c00
WM(finalizeNativeWindowWrapper) - ref=0x42e94c00
WM(finalizeNativeWindowWrapper) - ref=0x42e8f800
WM(finalizeNativeWindowWrapper) - ref=0x42e81000
WM(finalizeNativeWindowWrapper) - ref=0x42e77c00
WM(finalizeNativeWindowWrapper) - ref=0x4d6dd800
WM(finalizeNativeWindowWrapper) - ref=0x4d6cf400
WM(finalizeNativeTransactionWrapper) - ref=0x3592c000
EGL(finalizeGraphicsSurface) - ref=0x358ea000
EGL(finalizeGraphicsSurface) - ref=0x3591bc00
WM(finalizeNativeWindowWrapper) - ref=0x358f0000
WM(finalizeNativeWindowWrapper) - ref=0x35929000
WM(finalizeNativeTransactionWrapper) - ref=0x4130ac00
WM(finalizeNativeWindowWrapper) - ref=0x3f456c00
WM(finalizeNativeWindowWrapper) - ref=0x3f45d000
EGL(finalizeGraphicsSurface) - ref=0x41301400
EGL(finalizeGraphicsSurface) - ref=0x41308400
WM(finalizeNativeWindowWrapper) - ref=0x41302c00
WM(finalizeNativeWindowWrapper) - ref=0x4130a000
WM(finalizeNativeTransactionWrapper) - ref=0x46d37c00
EGL(finalizeGraphicsSurface) - ref=0x46d26400
EGL(finalizeGraphicsSurface) - ref=0x46d30400
WM(finalizeNativeWindowWrapper) - ref=0x42f1b400
WM(finalizeNativeWindowWrapper) - ref=0x42f3cc00
WM(finalizeNativeWindowWrapper) - ref=0x450ce400
WM(finalizeNativeWindowWrapper) - ref=0x450d4c00
WM(finalizeNativeWindowWrapper) - ref=0x46d29800
WM(finalizeNativeWindowWrapper) - ref=0x46d35800
WM(finalizeNativeTransactionWrapper) - ref=0x4cf7a800
EGL(finalizeGraphicsSurface) - ref=0x4cf25000
EGL(finalizeGraphicsSurface) - ref=0x4cf62c00
WM(finalizeNativeWindowWrapper) - ref=0x4a541c00
WM(finalizeNativeWindowWrapper) - ref=0x4a662c00
WM(finalizeNativeWindowWrapper) - ref=0x4cf42000
WM(finalizeNativeWindowWrapper) - ref=0x4cf72000
WM(finalizeNativeTransactionWrapper) - ref=0x4e530000
WM(finalizeNativeWindowWrapper) - ref=0x4e738800
WM(finalizeNativeWindowWrapper) - ref=0x4e74c000
WM(finalizeNativeWindowWrapper) - ref=0x4ef0e800
WM(finalizeNativeWindowWrapper) - ref=0x4ef25400
EGL(finalizeGraphicsSurface) - ref=0x4fdd7800
EGL(finalizeGraphicsSurface) - ref=0x4fde0400
WM(finalizeNativeWindowWrapper) - ref=0x4fdd9400
WM(finalizeNativeWindowWrapper) - ref=0x4fde3000
WM(finalizeNativeWindowWrapper) - ref=0x4e538c00
WM(finalizeNativeWindowWrapper) - ref=0x4e530c00
THRTL: Out: 0 bytes
THRTL: In: 0 bytes
DOMBridge: shadowObjectsGCd called with unknown umpHandle -535957056
Signal level only changed - ONS not updated
Device's GPS is currently permanently disabled
location is 0.0
fileConnection opened
old date is: 1332190190
url: http://getvibly.com/listings/send
Signal level only changed - ONS not updated
Signal level only changed - ONS not updated
xml:
{"Listings":[]}
No stack trace
Signal level only changed - ONS not updated
Signal level only changed - ONS not updated
Fastdrawing jpeg width=600 height=75
JPGDEC 31 ms
Fastdrawing scaleShift=0
2ScaleARGB 600x75->480x60
ARGB total Scale 31 ms
Fastdrawing jpeg width=600 height=75
JPGDEC 31 ms
Fastdrawing scaleShift=0
2ScaleARGB 600x75->480x60
ARGB total Scale 31 ms
VBW:0x50033000
D:0x062c5010.
Signal level only changed - ONS not updated
VBW:0x4f9e2400
D:0x40bff8c4.
FocusHistory: Focus lost; App CreativeCore; Component net.creative.core.CreativeCore$AppScreen
FocusHistory: Focus gained; App CreativeCore; Component net.creative.core.util.ColorButtonField
If it helps, here is the code to the splashscreen.
public class CreativeCore extends UiApplication implements SystemListener
{
private static String DB_NAME = "associationDB.db";
public static Database db;
public static SQLManager sqlmanager;
public static LocationHelper location;
public static boolean sdCardPresent;
public static AdField adField;
/**
* Default Constructor.
* @throws Exception
*/
private CreativeCore() {
}
private void start(){
try {
pushScreen(new AppScreen(this));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* App entry point.
* @param args Arguments.
* @throws Exception
*/
public static void main(String[] args) throws Exception {
FlurryAgent.onStartApp("AJDRI92BCJP24M1Z528C");
CreativeCore app = new CreativeCore();
// If system startup is still in progress when this
// application is run.
if (ApplicationManager.getApplicationManager().inStar tup()) {
app.addSystemListener( app);
} else {
app.start();
}
app.enterEventDispatcher();
}
/**
* Main application screen.
*/
private static class AppScreen extends MainScreen
{
UiApplication _app;
String status = "-1";
/**
* Default constructor.
*/
public AppScreen(UiApplication app) throws Exception{
// Note: This screen just says "Loading...", but you could
// add a loading animation.
_app = app;
Bitmap pic = Bitmap.getBitmapResource(Display.getWidth() + "x" + Display.getHeight() + ".png");
add(new BitmapField(pic));
// Queue up the loading process.
startLoading();
}
/**
* Create the loading thread. Make sure to invoke later as you will
* need to push a screen or show a dialog after the loading is complete, eventhough
* you are creating the thread before the app is in the event dispatcher.
*/
public void startLoading() {
Thread loadThread = new Thread() {
public void run() {
// Make sure to invokeLater to avoid problems with the event thread.
//connectToXtify();
try {
location = new LocationHelper();
System.out.println("location is " + location.latitude());
} catch (LocationException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
}
// Determine if an SDCard is present
sdCardPresent = false;
String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements())
{
root = (String)e.nextElement();
if(root.equalsIgnoreCase("sdcard/"))
{
sdCardPresent = true;
}
}
String dbLocation;
String osVersion = DeviceInfo.getSoftwareVersion().substring(0, 1);
if(Integer.parseInt(osVersion) >= 7)
dbLocation = "/store/SDCard/databases/CreativeCore/";
else dbLocation = "/SDCard/databases/CreativeCore/";
// Create URI
URI uri;
try {
uri = URI.create(dbLocation + DB_NAME);
// Open or create a plain text database. This will create the
// directory and file defined by the URI (if they do not already exist).
db = DatabaseFactory.openOrCreate(uri);
db.close();
// Open a connection to the database file
FileConnection fileConnection = (FileConnection)Connector.open("file://" + dbLocation + DB_NAME);
System.out.println("fileConnection opened");
// If the file is blank, copy the pre-defined database from this
// module to the SDCard.
if(fileConnection.exists() && fileConnection.fileSize() == 0)
{
readAndWriteDatabaseFile(fileConnection);
}
CreativeCore.sdCardPresent = true;
// Open the database
db = DatabaseFactory.open(uri);//, databaseOptions);
sqlmanager = new SQLManager(db);
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
} catch (MalformedURIException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
} catch (ControlledAccessException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
} catch (DatabaseIOException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
} catch (DatabasePathException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
} catch (IOException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
}
//the code below is used the get data from the remote database
String url = "http://getvibly.com/listings/send?";
url = url.replace(' ', '+');
String xml = new String();
//uncomment
xml = getData(url);
parseData(xml);
adField = new AdField();
adField.initialize(sqlmanager);
_app.invokeLater( new Runnable() {
public void run() {
// This represents the next step after loading. This just shows
// a dialog, but you could push the applications main menu screen.
try {
getUiEngine().pushScreen(new DirectoryScreen(sqlmanager));
_app.getActiveScreen().getScreenBelow().close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("in the runnable exception: " + e.getMessage());
}
}
});
}
};
loadThread.start();
}
public void readAndWriteDatabaseFile(FileConnection fileConnection) throws IOException
{
OutputStream outputStream = null;
InputStream inputStream = null;
// Open an input stream to the pre-defined encrypted database bundled
// within this module.
inputStream = getClass().getResourceAsStream("/" + DB_NAME);
// Open an output stream to the newly created file
outputStream = (OutputStream)fileConnection.openOutputStream();
// Read data from the input stream and write the data to the
// output stream.
byte[] data = new byte[256];
int length = 0;
while (-1 != (length = inputStream.read(data)))
{
outputStream.write(data, 0, length);
}
// Close the connections
if(fileConnection != null)
{
fileConnection.close();
}
if(outputStream != null)
{
outputStream.close();
}
if(inputStream != null)
{
inputStream.close();
}
}
}
03-20-2012 10:13 AM
03-20-2012 10:23 AM
The app is a business directory. While loading, it checks a server for updates, and if there are any, parses them and puts them in a database.
03-20-2012 10:28 AM
03-20-2012 10:49 AM
I am using a separate thread for all the network operations. The only thing on the main thread is the splashscreen.
03-21-2012 03:55 PM
The best way to determine what is causing the delay is to use the BlackBerry Profile view in Eclipse (it also exists in the legacy BlackBerry JDE if you are still using it).
To use it set a break point at the start of your application and another that would be hit after your splash screen has been hit. Once stopped at the first break point, click on the Window menu of Eclipse and choose Show View -> Other. Then in the window that appears expand BlackBerry and choose BlackBerry Profiler View. Then continue on to your next break point. This will show you the number and percentage of CPU cycles used by each method that was called.