iOS Action Extension slow loading time - ios

So, basically I'm trying to decrease loading times for an Action Extension I'm writing for IOS.
According to: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionCreation.html#//apple_ref/doc/uid/TP40014214-CH5-SW7
I should aim to get the loading time below 1 second (if it takes too long it might be shut down by the system prematurely)
Right now it loads in around 4 seconds on an iPad (a bit faster in the simulator) - so far iOS haven't shut down my extension, but this will be destructive for the user experience.
As far as I'm aware I don't have access to a AppDelegate.swift file when working with extensions, thus I'm having a hard time figuring out what is causing the slow loading times.
Does anyone have any idea where to look or maybe some experience with this?
Thanks!

The reason for the slow loading times was that I launched the app extension in debug mode. Running the app without the debugger it was significantly faster.
Did not consider this at all, but now it works like a charm :)

Related

What could slow down a iOS App over time besides Memory Leaks?

I have an app that adds a lot of UIClasses to many different Views. Views get removed and get added again. But then after some time working with the app, the app starts to slow down. Reloading everything, including the Viewcontroller, doesn't help.
The problem is, that i don't know what could slow down the app. The Memory Usage of the app doesn't go up and the CPU usage doesn't go up aswell. It just seems that the App does everything slower. Views take longer to get added to the view and so on.
Is there anything that i could check what could cause the app to slow down over time? I know that this question is very broad, but maybe someone of you can show me the direction to look at. I`m out of ideas.
It's hard to answer a question like this in the abstract.
I suggest using the Instruments tool and running a time profile. That lets you see where your app is spending most of it's time. You should be able to run the app for a period of time and see the culprit start to take more and more time as you run the app.

React Native - Improve cold start time

The project I was working is to use react native to create an iOS app.
Following is the cold start time in iPhone 5S release build
Pre-main time: 0.52 seconds
App did launch to javascript did load time: 2.12 seconds
JS render time: 0.74 seconds
Total time: 3.34 seconds
The slowest part is to wait react library to load the js bundle (2.2MB). Is the loading time looks normal? How can I improve the js bundle loading time? Thanks so much.
Reducing the js bundle size can improve the time from Application did launch to javascript did load. For a new Hello World project, it only took 0.18-0.19 seconds (iPhone 5S).
Yes, the problem that you described really exist. As a possible solution you can use ram-bundle format, that metro bundler provides.
In this case you will not load the entire js-bundle - you will load only part, that you need at a startup (in a lot of application are a lot of places, which user may not even see, and this feature allow you load such parts, only when they are required). So you can simplify your entry point and load only small piece of your bundle.
You can look at react-native-bundle-splitter. This library well integrated with almost all popular navigation libraries and allows you to postpone a loading of specific routes. For example, if you have a login screen, you can load at start up only this screen, and all others load in background or start the loading of them, only when user can see them. And the startup time of your complex application will be almost equally as for "Hello world" application.
Whether the time ok is up to you and your app users only =)
Obviously, if reducing the js bundle size improves the time, you should do your best to get it done. There is several steps I guess can help you:
first of all, DRY: doubling code do increase the size
check for using npm packages, remove unused (also as unused inner modules)
obfuscate and minify the bundle with third-party tools
Also it should be done to reduce initializing complexity
check an asymptotic complexity of your algorithms - is can cause to time increasing
remove unused variables, functions and data - it can be a reason of redundant memory usage
And I can just advice you also try to affect not only an actual time but also a time feeling. For example, use an animated splash screen

how to know that where exactly app getting stuck in xcode?

My app gets stuck for a specific operation and that operation is too big having so many method calls and services requests, so i cannot put breakpoints on each method and debug, is there any other way i can get to know where exactly my app is stucked in xcode?
The operation wasn't too big to write the code, so it isn't too big to add breakpoints, logging statements, assertions and so on.
The only other way that works sometimes is taking a long shower in the morning, not thinking about work at all, and suddenly the realisation what you did wrong jumps to your mind. It has worked for me sometimes, but the first method is more reliable.
If you have reason to believe that the most time is spent in one operation, just let it run with the debugger attached and then press the pause button and see where you are...
A somewhat niftier approach would be to start with Instruments (i.e. the Time Profiler). It's easy to use and should be the first weapon of your choice for performance issues.
You can set a conditional break point in Xcode to debug a specific condition, for more detail go through Jeffrey Sambells blog!

How to determine which processes are currently running

I'm trying to use Instruments to figure out what in my app is eating up all my battery life.
I thought Time Profiler would work here, but I can't figure out how to get it to tell me what processes are running after a certain point in time. Currently, Time Profiler tells me about all the tasks that have run since the app first launched, but I only want to know about the ones that are running right now.
Is there any way to filter Time Profiler in this fashion?
Found the answer - hold down the option key while dragging across the timeline.

willEnterForeground randomly restarts app

I thought my app was almost ready to ship, but this one thing is making me crazy!
In my didEnterBackground handler, I save some images to cache and dump everything I can possibly think of and the OS seems to randomly dump my app and restart it. It doesn't seem to be very consistent. Sometimes it comes back fine and sometimes I get a restart. According to Allocations, my memory usage is down to around 1 or 2 mb in my didEnterBackground.
And by dumping everything, I mean I remove subviews, remove objects from arrays and set a ton of stuff to nil...which means in my willEnterForeground I have to recreate a bunch of stuff.
I really don't know what else to do.
Any help here would be greatly appreciated. Thanks!
BTW, this is in iOS 5 and using ARC.
At the background state the app can always get killed by the watchdog. There is no guarantee that the app is always working in the background.
To learn more about Multitasking watch the Session 320 from WWDC 2011 there is a plenty of information about multitasking.

Resources