Ionic performance slow older devices - ionic-framework

I've built an Ionic 5 (with vue 3) app that uses BLE to measure airflow of an bluetooth airflow device (mainly Wöhler products).
These products constantly send out a reading of airflow measured.
The app:
A user presses a button in the app to start the measurement, a timer will show how long a user is measuring for and within at least 5 seconds the measurement has to be done.
The problem:
On older smartphones (mainly android) performance is very slow. The timer displayed ofthen does not represent "real" seconds, it's delayed, measurements on older phones often take 8 "real" seconds. The timer displayed:
const counterInterval = setInterval(async () => {
...
counter.value += 0.01;
}, 10);
Not only that but it seems the application can't keep up with the Bluetooth pings on older devices. Because (I suspect) the runtimeclock of the whole ionic application is slow sometimes I get no pings from Bluetooth devices, sometimes 5 in a row. I know for a fact the Wöhler devices send a ping every 100ms or so.
I've also tested a native application that almost does the same thing my app does, even on older devices there is no delay and the app receives all the pings sent.
My question:
Is it normal for Ionic apps to perform significantly slower than native apps when running on older devices (4 years ago).
Is there any way I can improve performance? (bundle size is very low, I don't import fonts or images)
Personally I've tested with:
Redmi 9A (timer and bluetooth is slow)
iPhone 8 Plus (timer is fast)
iPhone 12 Pro Max (timer is fast)

Related

Why iOS app iBeacon wake up intervals varies?

Hi i have a swift app that communicate with a BLE device with a beacon.
When i kill the app the beacon wake the app in background and it connect to the device and start communicating.
The interval of detection / connexion mostly take between 30 sec to up to 1 min after i kill the app. but sometime it take like 3 4 min.
Did anyone faced such issue and have an idea of whet could be happening it's the same process why it vary from time to time did it have a relation with the device itself ?
thx
Since iOS is closed source, it is impossible to say with certainty why delays in beacon detection happen. This is especially true in individual cases -- there are lots of variables.
However, we do have some ideas of how iOS CoreLocation manages to detect beacons based on reverse engineering, and I have some insight on based on building the Android Beacon Library which uses similar concepts.
Here is what we do know:
CoreLocation uses BLE hardware filters for pattern matching to get detections as quickly as possible. If a hardware filter slot is available, beacon monitoring will use the Bluetooth chip itself to look for a pattern first matching. This will give you a detection in less than a second when a beacon first appears.
In some cases hardware filters cannot be used (they are exhausted) or the beacon is known to be in the vicinity, so it is ignored. In these cases, a periodic backup scan is used to look for beacons.
The backup scan happens at different rates depending not the state of the phone and the beacon/bluetooth scanning state of apps running on the phone. If no apps are actively scanning and the screen is off, this can be every few minutes.
When the screen is turned on, it typically triggers a backup scan.
If your app is visible in the foreground and using ranging APIs or actively doing a BLE scan with CoreBluetooth, it is scanning at a 100% duty cycle.
In other cases, the duty cycle will be lower. If you are testing with a beacon that does not advertise frequently (e.g. less than the 10Hz in the iBeacon spec) it may miss detections at 10% duty cycle scan.
A few things to consider based on your description:
You may have exhausted all of the BLE hardware filters on your phone, and your app may not be getting one. Unfortunately, this optimization is completely hidden, so there is no way to tell for sure. You can increase the chances of getting a hardware slot by uninstalling any apps you think may be scanning for Bluetooth, then uninstalling and reinstalling your app, and restarting the phone. If all else fails, do a factory reset on a test phone.
Whenever you reboot your phone, it takes much longer for things to be fully booted than it appears. Location services are amongst the last things to be fully initialized. Always wait 5 minutes after reboot before doing any time-sensitive testing.
It takes time for iOS to detect it is in an out of region state with a beacon. This is typically 30 seconds if the app is visible on the screen, but if it is not, it may take significantly longer because of the timing of backup scans. And you cannot get a new region entry event if iOS doesn't realize you have exited yet.
If you kill your app when a beacon is visible (or when it had recently been visible) iOS may not know the in region / out of region state. If it thinks it is in region when it is not, it can take a long time to figure out it is out of region.

How to synchronize an audio on 2 or more ios devices

I have to perform an action (play song at a time on multiple devices without lag) at a given point of time. My requirement is that the app should not use any internet connection. So I need an exact point of time when to play data(Audio)]
I have already tried following:
Play song after 5 seconds on all devices. (still causes lag of milliseconds)
Send a small text notification to identify playing of the song and then start playing on all devices. But sending and receiving this notification takes time of milliseconds :(:(
Set time to automatic on all devices and then checked time difference of text message passing, It has milliseconds gap in each testing.
First you need to synchronize the 2 devices internal time.
Apparently the most accurate clock you can have on iOS is the absolute time by doing :
CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
Then you need to send this time from device A to device B retrieve the difference on device B and send it back to A , then compare the difference with the time spent in the network transaction. In this way you can have a quite accurate synchronisation of the 2 devices time. (This is presuming the network time is symmetric between request and response and that there is not much overhead on your calculation on device B).
From there you can easily instantiate 2 AVAudioPlayer on the devices set the song and call prepareToPlay and finally fire the play method according to the delay on the synch.
This should give you a not noticeable precision.
Another route you can take is the one of placing an AudioUnit on the second device connected to the microphone in order to sync the music accordingly to the first device emitted sound.
Known Issue
When sleeping or waiting for extremely precise time intervals, timers may be delayed by up to 1 millisecond.
For reference :
https://developer.apple.com/library/ios/releasenotes/General/RN-iOSSDK-7.0/

How to run ios application in background on device restart?

I am working on Location Tracking Application. This application continuously send location even in background. I am using SLC property.
I am also using silent push trick for location tracking. Logic of Silent push:
Check AppIconbadge number and perform the action according to AppIconbadge number. I have a timer which check AppIconbadge at every 10 seconds.
Now this is the case:
Device is on SLC and put the app in background and turn off the device. While you switch back to On this device it is still reporting on SLC while Ping (Silent Push) is not working.
I have started the timer when app get SLC trigger. But its not working.
Can you help?
You can't do it.
The way iOS achieves great battery life and reduces RAM usage makes this kind of thing impossible.
Your only real possibility is to have your server send occasional push notifications to the device, and have your app on the device respond with its location. This is how Find My Phone and Find My Friends both work. The idea is to improve battery life by doing as much as possible on a server, which has mains power and virtually unlimited RAM, instead of on the phone which only has a battery and might need all it's RAM to play a 3D game
Basically the CPU is not running at all most of the time, so it can't schedule stuff to run periodically, and you can't rely on there being enough RAM available to run your app so it also can't be running all the time even if the CPU is powered on.
According to the WWDC 2013 keynote, push notifications are much more powerful on iOS 7, so you should look that up (I haven't looked into it myself, just saw the keynote.

Max application memory Limit in iPad?

I have created iPad application which downloads images using web service. But my application crashes somewhere during manipulating with high quality images. So my question is - what is max memory limit for application running on iPad? When does the application hit LowMemoryWarning on iPad?
There is no per-application limit so to say. The amount of memory available to an application depends on the amount of free memory, which again depends on the amount of memory used by applications running in the background. These apps include permanently running system apps like SpringBoard, sometimes running system apps like Safari, iPod, etc and (when iOS 4 will come for iPad) user-apps that still run in background.
Nevertheless, I'd say an app should never use more than 50% of all available ram. On iPad this currently means 128 MB and should be quite a lot. Did you do a leak check on your app?

Emulate a slow iPhone

I have an iPhone app (Objective C++). My beta testers - some of them, not all of them - are complaining of slow startup, 7 to 10 seconds. On my device (it's a 3GS), it loads in about 2 sec. On the device simulator - even faster. As things stand now, I cannot even isolate the bottleneck.
Can I somehow slow down the simulator or a fast device? Setting the simulated hardware version to 2.0 does not help.
As a last resort, I could try and borrow an old, slow device from a friend for a night or two. But I'd rather not...
If I were you I'd try profiling the startup with Shark - it's hard to profile startup on the device, one way is to put a 5-6 second sleep statement in ApplicationDidFinishLaunching so you have time to attach Shark and start recording, don't make it too long though or the app will be killed!
Also consider what you are doing on startup that might be a lot longer for some people - looking at address records, or things like that.
Aral Balkan links to some nice tools by Mike Shrag that allow you to get the old slow motion simulation mode on triple shift working in SDK 3. Speedlimit - which allows you to throttle network bandwidth might be useful.
This is an old question, but one option is to use a non-SSD iMac or MBP to test on a slow environment. The latest Xcode versions and simulators (XC version 7 for sure) run extremely slowly on non-SSD devices. More slowly than any actual phone...