React native performance simulator vs. real device - ios

I have some questions about the performance of a react native app.
I'm developing a react native app (RN 0.62.2). I'm testing on various IOS simulators as well as on a real device (iPhone 7, ios 13.3).
I'm mostly using the simulator because it's the fastest way to check the output of the code, but when I'm testing on my iPhone 7, I see some performance issues.
First of all: I'm using react navigation. When I open the perf monitor on the simulator and I navigate to a new screen (in the same stack navigator), the JS thread drops with about 6-8 frames (from 60 to 52-54). On the real device with 18-20 frames (from 60 to 40-42). I navigate to the exact same screen.
Secondly, I load local images through require. On the simulator, they appear almost instantly. On the real device, it takes some time before they appear. For example, I have a screen with a background image. On the simulator, it's instantly shown. On the real device however, it takes about a second to load.
I'm using a lot of animations in my app. I'm using reanimated to run the animations on the UI thread. In the simulator, they all work very smoothly, but on the real device, it seems like they are having some issues. They're not that smooth as on the simulator.
Another thing: when entering some text in a textinput (text is stored in a useState-variable while typing through onChangeText={v => setValue(v)}. Frame drops about 6-8 frames on the simulator, but again around 18-20 frames on the real device.
My question now is: what could possibly be the reason for this difference in performance? I've come up with some possible answers, is one (or more of them) correct?
Reason 1: metro server
I'm testing on the real device, so the react native code is still on my laptop. The app is not running on my phone yet, so all request go through the cable which connects my phone to my laptop. This results in some lag.
Reason 2: old device
My iphone 7 is old. I'm running ios 13.3 but the iphone is almost 4 years old. However, when I test on an iphone 7 simulator (ios 11.4), it all works smoothly.
Also I noticed something weird: running the same app in the simulator consumes about the double of RAM memory then on the real device. In the perf monitor on the simulator, when I open the app, or I do some actions, there is more RAM memory used than on the real device (around 30-40 mb, sometimes around 70-80 mb, depeding on the simulator type and ios version).
I have not tested it with a release build yet because my app is far from done. Is there a performance difference between an app testing through the metro server and a release build?
Edit:
I've tested the release build instead of the debug build on my real device. I see a better performance than in the debug build, so that's good. The problem now is: I can't check the perf monitor. Does someone know a good tool to check the performance of a release build?

Great question!
Not aware of any means to run debugger against a Release build. That said - you can run a Debug build on your physical device.
Connect device to Macbook
Open ios/.xcworkspace in XCode
Choose your device and Product -> Run
You'll have access to all the typical debugging niceties - Inspector, debugger, Performance monitor. Assume your Release builds will run faster than Debug builds.

Related

Is the iPhone Simulator actually as "slow" as device itself

I wanted to know whether the iPhone Simulator in XCode "really" emulates the device hardware.
So when deploying to iPhone 4s Simulator, will my app actually be "as slow as on a real iPhone 4S device" and when using an iPhone 6 Simulator, will it be as fast as on a real device?
The simulator does a really lousy job of indicating app performance. In fact it doesn't try.
For most things the simulator is much, much faster than an iOS device. It runs your code on an x86 processor, which is much faster than the ARM and has many times more memory. (It also actually links again OXS frameworks, not iOS frameworks. There is glue code in the simulator that makes it work with iOS code, but it's not perfect.)
However, some things, like Core Image filters and OpenGL graphics, are actually slower on the simulator than on a real iOS device.
The bottom line is that you can't really tell ANYTHING about your app's performance from the simulator, and shouldn't try. You can do basic development on the sim, but when it comes time to test performance, use real devices, and make sure to test on the oldest/slowest device your app supports (usually an iPhone 4s or iPad 2).
You also can't test memory usage on the simulator. A program that will run out of memory and crash on an iOS device may run just fine on the simulator.
The Simulator is a useful tool, and it should not be the only way you
test an app. Because the Simulator is an app running on a Mac, it has
access to the computer’s resources, including the CPU, memory, and
network connection. All of these resources are likely to be faster
than those found on a mobile device. As a result, the simulator is not
an accurate test of an app’s performance, memory usage, and networking
speed.
Source

Slow app performance under iOS 8 simulator with Xcode 6

After upgraded to xcode 6 I found that when I run my app under iOS 8 in iOS simulator, it ran very slowly, no matter when I choose iPhone or iPad. But if I choose it to run under iOS 7 it ran normally.
I was thinking that it was an app/coding related problem so then I tried to deploy it on my ipad with iOS8 and strangely the app run normally, not as slow as simulator does
Does anybody on SO experience this issue?
Make sure 'slow animations' is not selected under the Debug tab in the iOS Simulator. That fixed the issue for me. It might have been turned on by accident.
If you hit ⌘T while your simulator is selected it will turn on 'slow animations' which puts everything in slow motion. ⌘T is often used to open up a new browser tab, so just be sure your browser is selected and not your simulator.
Performance in the iOS Simulator is not expected to match performance on device. The iOS Simulator is meant as a tool for rapid prototyping and fast iteration. Performance tuning needs to be done on real devices.
Processes running in the iOS Simulator are basically OS X processes running in a specially crafted runtime within a special bootstrap to behave like iOS rather than OS X. Over the past 4 years, this has evolved from basically UIKit and similar iOS Frameworks built on top of OS X Frameworks to now having our own bootstrap server (as of iOS 7), our own dyld (as of iOS 8), and only sharing the host kernel and very low level system libraries (libSystem as of iOS 7, and just the pthreads, syscalls, and platform children of libSystem as of iOS 8).
When you test an app on a device that is not currently booted, we shutdown the device and boot the new one, and that process can take 10s to a minute or 2 to complete based primarily on your disk's I/O bandwidth and what other tasks on your system are demanding of it.
If you see major performance issues with a sim device that has been booted for a while and don't have any obvious background tasks running (compilation, rsync, whatever), take a sysdiagnose and take a look at the simulator processes in the spin dump and fs_usage to see what's likely going on.
Performance simulation and device different things. I think you should not pay attention to it. This error can optimize apple

iOS and Cocos2d: my app REALLY slow on simulator but is FINE on device

..I am wondering whether there is some setting I should change to get my iOS 5.0 app running fine on an iPhone IOS 5.0 simulator. It runs at only 12fps instead on my device runs at 60fps. Any help? I would have expected the simulator to work fine..
I am using XCode 4.3 and Mac OS X 10.7.3.
Simulator performance is completely and utterly irrelevant. The Simulator runs on your Mac's CPU, that's multiple times faster than the fastest iOS device. The Simulator does however not use hardware graphics accelerations, so it's easily maxed out even though your Mac is so much faster. Lastly, which of your app's users are going to run your app on the Simulator? Answer: no one!
That said, there is still reason to be alarmed. You get 60 fps on the device, that's great. But which device? If it is an iPhone 4S or iPad 3, that device is a lot faster than older devices like iPhone 3GS (or even older yet) or iPad 1. So depending on which device is the oldes device you're developing for, you might still have a problem. Try to find or borrow such a device, and test it on that oldest-supported device, and do test only with a release build.
Consider the facts:
Simulator performance sucks
Retina Simulator performance sucks even more
iPad Retina Simulator performance is beyond good & android
You're most likely the only person ever to run your app in the iOS Simulator
Therefore:
Simulator performance is irrelevant
Simulator performance can not be compared to device performance
The Simulator is for quicker testing of your app's business logic, nothing else. Not even Samsung copied it.
In addition:
Debug build performance is largely irrelevant. At least verify performance measurements in release builds.
Test on oldest supported device. Otherwise you have no way of knowing whether the previous generation device from the device you're testing on may still render 60 fps or only renders 20 fps. That's quite possible.
Lastly, to answer your actual question: the only thing you could do is to make sure you run the standard (ie non-Retina) resolution Simulator. There's really nothing else you can do besides getting a Mac with a (much) faster CPU.
For graphics, par for course. Dont use simulator for any user experience validation, but stick to devices. Dont waste a minute trying to tweak your workstation settings or looking for ways to improve simulator performance. In any event, your are trying to deploy to devices after all no ?
Some functions work faster on simulator (depending on your workstation of course), like data or computation intensive functions. As always, benchmark on your devices, dont be fooled by 'suitable' simulator performance.

Using iOS Simulator to emulate iPad 1

One of my customers is experiencing terrible slow downs only on the iPad 1 device. Is there any way of getting the iOS Simulator to emulate the performance/hardware of the original iPad?
I would rather not have to go out and buy an iPad one as iOS 6 won't support it this autumn.
The app runs fine on the iPad 2 and 3. I have tested using the allocations and activity instruments.
Any ideas? Thanks again. The OS is 5.1.1 and the App was compiled with XCode 4.4.1.
As far as I know, the simulator is what it says, a simulator, and as such will run as fast as it can on whichever computer you're using. You'll probably need to put delaying code into your run loops to simulate the slowness of the iPad 1, but maybe your client needs to be aware that the iPad 1 is much slower than the newer models - there are certainly some (particularly graphic intensive) operations which will struggle - you may find you need to adapt the user experience according the the device being used (Apple don't encourage this - they prefer you to check the iOS version - but there are several questions on SO which could help you here).

phoneGap app for iOs: if application works in xCode device emulator

I've got a newbie question about phoneGap and creating apps for iOs.
If my phoneGap app runs in device emulator in xCode and everything is ok, can I be sure that it will work the same way on a real iOS device when I publish it in the appstore?
The XCode simulator does what the name suggest - 'simulates'. It is not identical to the actual hardware, for a number of reasons. Here are just a few of them:
Performance - your computer has much more memory and processing power available than the phone itself. Your app may run fine on the simulator, but quite slow on the device. This is why it's a good idea to run on the device itself, especially if you're doing stuff which could use up a lot of memory.
Missing features - the simulator doesn't allow certain things to be tested, like in app purchase or media/asset management. And obviously you're missing things like the camera, the accelerometers, compass, etc. You can from iOS 5 simulate certain things like the GPS, but nowhere near everything.
Visuals - the simulator runs at your monitor resolution, whereas the phone itself has a much higher DPI display. Things that look readable or fine on the simulator can on device look very different.
If you're not testing your app on an actual device before releasing it to the app store you're doing a disservice to your users - this is Apple's point of view, and one shared by most developers. It's not necessarily what you might want to here, but unfortunately the simulator really is just that - a simulator. You wouldn't want to be in a plane piloted by somebody who had only trained on a simulator. And you probably wouldn't want to use an app that had only been run on the iOS simulator.
Here's what Apple have to say about it in their own documentation:
Although you can do much of your debugging and testing of an iOS application using iOS Simulator, simulation cannot completely match the results of running your application on the target devices; you must test your application on actual devices to ensure that it runs as intended and to tune it for performance on actual hardware.

Resources