App too sluggish on Android, but OK on iOS

I have written an app the uses a Timer to trigger a location sensor. The information from that sensor is used to compute the distance traveled in a car (an odometer). The app works properly on the Web Preview as well as on Thunkable Live on my 4 year old Apple 6S iPhone. However, the app will not work properly on Thunkable Live on either my Android Motorola phone (running Android 11) or on my Android Samsung Tab A7 tablet (running Android 12). Specifically, the lag time on any button press exceeds 60 seconds when the timer is set to fire once per second. If I change the timer to fire once every 5 seconds on either Android device, the buttons function properly and immediately. But the nature of the app requires that it get a new location once a second. The screen contains 638 blocks, but I’ve tested a cut down version with half as many blocks and the problem remains. I’m open to suggestions on how to make this app run on Android while calling the location sensor once per second. Thanks for any advice.

Is your Android device slow, does it have a lot of files?

Emlee703,
I don’t think so. Other apps run fine on both my Android Motorola phone and the Android Samsung tablet. I make sure that there are not any other apps in the background when I test. I thought that perhaps the Thunkable Live overhead was causing the problem, so I downloaded a version and it ran the same way.
I have verified that as I increase the timer interval, the lag time for any button to respond changes. 5 second interval makes the buttons work properly and as I reduce the timer interval the lag time for button response increases. At a 1 second timer interval the buttons either take more than 1 minute to respond or don’t respond at all.
I’m wondering if there is some fundamental difference in the implementation of location sensor in Android vs iOS.

Send the link to the app for me. I have a Samsung Galaxy A13, I can test it later today, when I have a chance.

Emlee703.

Here’s the link:
https://x.thunkable.com/copy/c13945d548a832ef5783c7df8147e1d1

It is Timer 1 on the Main Screen that affects the button lag. That time is currently set a 1 second interval. I expect that when you test it the buttons will not respond. If you adjust Timer 1 interval to 5 seconds I believe you will see a proper button response.
Thank you very much.

I can’t test it on my phone now, because I’m totally not in school right now (the teachers allow it, because its all fun today, no work)… Anyway, I will be able to test on the phone later today. But the first thing I see when I click the link. The lag!!! There is so much going on my computer said “nope!” and crashed.

Did your computer crash when you tried to run this app on Web Preview or when you just opened the app?

When I opened the link, and went to blocks, but also Design is really laggy.

The only reason why I think it is so laggy, is because they are like a billion things on one screen.

I didn’t even test it on my phone yet, and already I think I see the problem.

Seems like iOS, just, can deal with faster Thunkable Apps. But I will still test on my phone later anyway, just to see what will happen…

May I suggest trying to change the interval for Timer1 in Main screen from 1 second to 5 seconds first in order to see how it should run?

I can’t even get to the Timer before the project crashes :rofl:

Once I warmed up my computer, I tested it on WebPreview and its actually fine (one I warm up my computer). Once I’m out of school, I will test it on my phone for it to become the next victim. (I did change the timer from 1 second to 5 seconds).

I look forward to hearing your result on your phone. Thank you.

1 Like

@james.a.crittenden02 I tested the app on my phone (Samsung Galaxy A13), and while the timer was working correctly, when clicking the buttons, there was a HUGE delay, for the transition triggered by the button to take place. (Almost 45 sec)

My guess for the reason why this is happening is just the huge amount of assets and buttons and all that fun stuff, stuffed into only 2 screens.

BTW; does it lag, when you’re editing the project?, because just opening that link you sent me, took me through the Thunkable dimension of lag, are you experiencing the same?

Emlee703,
Thanks for testing the app. When I’m editing the project on my Lenovo laptop there is no discernable delay. And the project runs fine on my Apple 6S phone on Thunkable Live with a 1 second interval on Timer1.
If I can’t get the app to run with a 1 second refresh rate on Android then I won’t be able to use Thunkable.

I think different devices, process stuff differently. My phone, again the timer is fine, but the buttons have a 45 second delay. I think the only way to fix this, for it to be compatible with all devices, is to create more screens and spread apart the assets. You just have too much, on 1 page, and some devices can’t process it.

Thanks. I will experiment with some different approaches and try to find one that works.

1 Like

@james.a.crittenden02 No problem!
Heres a tip; try to copy your project, and then on the copy, take all the blocks out, cause usually that is what causes the most lag. Then try to find a more efficient way to fill in all the blocks. I would try this with a copy, since you don’t want to get rid of your original, before you even came up with the replacement blocks.

Excellent idea. Will do.

Emlee,
I added a block to display Timer1’s “Time in milliseconds” as the last block in Timer1’s DO list. Apparently that displays the number of milliseconds that have elapsed since Timer1 fired. So it shows how long it takes to execute 3 functions that are called by Timer1.
What I’ve found is that Web Preview on my laptop shows 110 milliseconds in this field. My Android Motorola phone shows 400 milliseconds and my Samsung tablet shows 760 milliseconds.
I think this shows why the app works on my laptop and not on my Android devices.

:+1:
I think we found the main issue! Nice work! @james.a.crittenden02
Getting rid of the timer should help, or modifying it a little.