Android Question tiny screen and delay

kje

Member
Licensed User
Longtime User
B4A App starts with tiny (minimized) screen and waits 15 seconds before showing the real size screen.
Using a phone with Android 8.1.0. The Layout is for size 720x1440.
See screenshots.
What could be wrong?
 

Attachments

  • Screenshot_20191006-180644.png
    Screenshot_20191006-180644.png
    341.9 KB · Views: 253
  • Screenshot_20191006-180706.png
    Screenshot_20191006-180706.png
    205.8 KB · Views: 244

emexes

Expert
Licensed User
The silence on this thread is because you haven't really given us much to work with. Your screen looks pretty good, so presumably you're an experienced programmer. Perhaps it's just that you're under pressure and are experiencing brainfreeze. Happens to the best of us ;-) Here are some random ideas, hopefully one of them will spark an aha! moment :)

Does it gradually increase to the larger size, or stay small for 14 seconds and then jump to large size?

First thought would be to search for Sleep statements. Did you use any during earlier debugging?

Second thought would be to track down the point of execution where it changes from small to large.
- Log the start and end of the initialization code.
- Log a main-loop counter.
- Log every LoadLayout call.

Third thought is that perhaps your program is using 100% of available CPU, thus nothing left for background/UI/low-priority tasks.
- What happens if you put a Sleep(100) millisecond delay after the LoadLayout (which will give the UI a chance to update the display).
- What happens if you put a Sleep(20000) 20 second delay after the LoadLayout - does it still grow large at 15 seconds through the 20 second delay?
 
Upvote 0

kje

Member
Licensed User
Longtime User
This seems to be a great community.
To be honest, I even didn't expect an answer. So Thank you very much.
I will take your advises into account.
But first of all I installed the app to an old Samsung node with Android 6.0.1 and the result is:
The first screen is not so small as on the other phone (Gigaset 100) and the delay before the right size is shown is only 1 second.
I'm also using text to speech in this app and the difference between the phones is: It takes two minutes to speech output on the Gigaset after the first click on the relevant button, then the speech comes synchronously after button clicks. This effect in not on the Samsung. The speech starts immediatley after relevant button click.
It seems to be that the Gigaset processor is extremely slow.
 
Upvote 0

emexes

Expert
Licensed User
This seems to be a great community.
+1 aside from the occasional flareup (usually thanks to a mistranslation)
To be honest, I even didn't expect an answer.
The advantage of pessimism - life is full of bonus surprises!
also using text to speech in this app ... two minutes to speech output on the Gigaset after the first click ... Samsung. The speech starts immediately after relevant button click. It seems to be that the Gigaset processor is extremely slow.
What about after the second click? Is it possible that the language data is preinstalled on the Samsung, but has to be downloaded on demand to the Gigaset? Or that the libraries work differently in some fashion? How can we pin down that the two-minute delay on the Gigaset is a processing-speed delay, and not a download delay? Do other voice-output apps have the same speed difference between the two phones?
 
Upvote 0

kje

Member
Licensed User
Longtime User
It is realy the TTS lib which makes trouble.
My app has three modules: main, seite3, seite4.
Text to speech is only used in module "seite3". But unfortunately I had the lines
"Private tts As TTSID" and
"tts.Initialize(Me,"TTS")"
also in the main page. Now I deleted both lines from main and now the app starts immidiately with the right screensize.
During start of module "seite3" however it takes now the 15 seconds again (on the GIGASET) because of initializing the tts.
Well I have to check now if it is possible to preinstall the tts-Library on this phone.

Its always helpfull to talk about such challenges with others instead of trying to solve everything on your own.
Thank you.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Its always helpfull to talk about such challenges with others instead of trying to solve everything on your own.
Thank you.

+1
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
HI
You can try to increase the memory on the stack. Add this to the manifesto. Only such a solution is not always desirable.
B4X:
SetApplicationAttribute(android:largeHeap,"true")
 
Upvote 0

kje

Member
Licensed User
Longtime User
Thank you, I tried it but this had no effect at all on the Gigaset phone. It takes still the 15 seconds to load the tts.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Looks like that is (as you determined) an issue with TTS. Support for your determination:
1) https://stackoverflow.com/questions/27892462/android-text-to-speech-is-very-slow-to-initialize
2) https://stackoverflow.com/questions/17258363/text-to-speech-app-ui-is-slow-android/24398365#24398365
One solution mentioned in the above posts is to do the OnInit in a separate thread. You should be able to accomplish something similar by (throwing some ideas at the wall):
1) Creating and initializing the TTS object in Starter
2) Create a separate service module and use it to start the TTS object.
The method exposed by either could can then be called via a CallSubDelayed. Then have another method that you can call to see if the TTS object is done initializing. Or you can use Wait For with the exposed method (and therefore not blocking the UI).
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The Gigaset GS100 phone seems to be a budget phone with a slow CPU/GPU and slow internal memory. Is it going to be worth the effort to try to get your app running better on this when the performance seems to be already acceptable with on an outdated Samsung and probably better still on more recent mid-range phones?
 
Upvote 0

kje

Member
Licensed User
Longtime User
Thanks to all.
I installed the App now to 3 different phones/Tablets:
Samsung Galaxy Note 4, Android 6.0.1
Lenovo TabA2107A-H, Android 4.0.3
Gigaset GS 100, Android 8.1.0

Result is: only the Gigaset shows the 15 seconds delay during installing TTS, all others come up immidiately.
 
Upvote 0
Top