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
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T
Accepted Solution

5 seconds delay on PushScreen

I am using a 9930.  For the screen shots, it is using a 9650 from the simulator.

I developed the application in OS 6.

 

The main screen uses the Button List to display the menu options.  When clicking on any of the menu options, there is a 5 second delay until the screen appears.  It doesn't matter what is on the screen being loaded.  Some of the screens have to fetch data for a drop list, but one screen is only a short form with 3 text boxes.

 

In an attempt to make the transition quicker, I wrapped each of the PushScreen calls with an event lock.

switch(field.getIndex()) {
        		//serviceOrdersBut
	        	case 0:
	        		buttonName = "Service Orders";
	        		synchronized(UiApplication.getEventLock()) {
		        		ServiceOrderScreen serviceOrderScreen = new ServiceOrderScreen();
		        		UiApplication.getUiApplication().pushScreen(serviceOrderScreen);
	        		}
	        		break;
	        	//createSOBut
	        	case 1:
	        		buttonName = "Create Service Order";
	        		synchronized(UiApplication.getEventLock()) {
		        		CreateServiceOrderScreen createSOScreen = new CreateServiceOrderScreen();
		        		UiApplication.getUiApplication().pushScreen(createSOScreen);
	        		}
	        		break;
	        	//viewSiteBut
	        	case 2:
	        		buttonName = "View Site Information";
	        		synchronized(UiApplication.getEventLock()) {
		        		SiteScreen siteScreen = new SiteScreen(0);
		        		UiApplication.getUiApplication().pushScreen(siteScreen);
	        		}
	        		break;
	        	//partSearchBut
	        	case 3:
	        		buttonName = "Search for Parts";
	        		synchronized(UiApplication.getEventLock()) {
		        		SearchForPartsScreen searchForPartsScreen = new SearchForPartsScreen();
		        		UiApplication.getUiApplication().pushScreen(searchForPartsScreen);
	        		}
	        		break;	
	        	//retrieveInfoBut
	        	case 4:
	        		buttonName = "Retrieve Information";
	        		synchronized(UiApplication.getEventLock()) {
	        			RetrieveInformationScreen retrieveInformationScreen = new RetrieveInformationScreen();
	        			UiApplication.getUiApplication().pushScreen(retrieveInformationScreen);
	        		}
	        		break;	

 

 

 

6OS_MainScreen.png

 

Any suggestions on how to speed this up?

 

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 16,676
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: 5 seconds delay on PushScreen

are you retrieving data on the event thread?
you should move all blocking calls, for example networking, to a separate thread. show a loading label or something on the new screen until the data is available.

see
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865
----------------------------------------------------------
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
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: 5 seconds delay on PushScreen

Hi @

 

1. If possible, remove the initiation of your objects out of the synchronized scope. No need to do these tasks on the UI thread. The only thing that needs to be in the UI thread is the pushScreen.

 

2. Make sure all blocking actions (networking, DB tasks, etc') are done OUT of the UI thread.

 

Hope that helps,

 

E.

 

Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: 5 seconds delay on PushScreen

The issue had to deal with adding a Log entry at the action "click" and the load of the screen.

 

Basically, in order to track what the user was doing so we can debug their issues later, we added a log feature that tells us what action they did or screen they viewed or error they encoutered.  This gets put into a Log table which is sent down on occasion.

 

 I created a class for each of my tables that handles Inserts, Updated, etc... So, then I just call the Log.Insert(Command, Type, Description) to add the Log activity.  I removed all of my Log insert calls and it has sped things up so there is no delay now.

 

So, I guess I need to figure out why my SQLite inserts aren't optimized to go faster.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: 5 seconds delay on PushScreen

I'll take a look at this and see if I can clean up my code.  Thanks.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: 5 seconds delay on PushScreen

I actually didn't have those synchronize calls in there initially.  I put them in there to try to see if that would speed things up. 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: 5 seconds delay on PushScreen

Locking the event thread will never "speed things up". Glad you got yourself sorted seeing that this "logging" action was not shown in your code snippet.

Developer
Posts: 16,676
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: 5 seconds delay on PushScreen

sql is an i/o operation and should be done on a separate thread.
your UI does not have to wait for the logging to complete, so there would be no need to synchronize in any way.
----------------------------------------------------------
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
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: 5 seconds delay on PushScreen

Now I know.  :smileywink:

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment