Crashes after brought back from background - ios

I have an app pretty much completed at this point.. there's alot of animation methods being used and it's based on a storyboard using ARC. At the finish point it now seems that a user will crash occasionally when the app is brought back from the background (the tablet locks) and app is still lives but is brought back to foreground. When you click a button.. boom.
Any general advice to deal with a problem like this.. Just a general path to take to debug such a problem. I started by making sure all objected are nil'd on memory warning etc.. hard with ARC because.. well who knows what's going on.
Any general direction would be appreciated.

Have you added the generic breakpoint to break "On Throw"? This will stop the app as soon as the exception is raised, rather than after it traverses the entire stack (uncaught). Very useful. Brief instructions:
Go to Breakpoint tab in XCode (6th from left in the left side pane).
Click + button in bottom left
Choose Add Exception Breakpoint
Keep the defaults by pressing done
I developed for 5 months before I learned about this basic function in the Debugger (Sept 30, 2011) video from iPad and iPhone Application Development course from Stanford in iTunes U (free).
Enjoy,
Damien

ARC is definitely your friend - stick with it and your life will be much easier. First things first: Run your application under instruments (simulator is fine to start) for "Zombies". Hunt down any red "leaks" detected until none are left.

Related

Magic Leap Menu UI disappear

Im using Magic Leap One: Creator Edition almost everyday for Unity Development, but I stumbled across the following issue:
Magic Leap does not show anything (Menu and icons) when I start magic Leap device. I see the starting screen with and astronaut flying with text TAP TO START. I click, as usual, and it takes around 30-45 seconds to load and everything disappears (No UI/UX of Menu with app icons). Sometimes I get pop up message Scan Area and when I scan it popups with Area Recognized and still nothing happens after scanning. Even after closing all applications and restarting the device, the same issue arises.
What could be the cause? What can I do?
I found the mistake I made. I changed the models for Icon and Portal with unsupported high polygon models from asset store. If you want to avoid this trouble, follow guidelines for icon and portal asset development.

iPhone app Debug Is very fast but (Adhoc and appstore) Release is very slow

Does anyone know of any potential causes of chuggy slowness through out an iPhone app, as a result of some kind of config or third party library in the release version of an app?
I have libTestFlight, libGoogleAnalytics, libBlitFeedback, MKNetwork as well as Bolts, NewRelic, Parse and the Facebook SDK... everything else is a standard iOS SDK library.
When I build for Debug, she runs lightning fast... I simply change to 'archive' and release the app on test flight and walah it runs like a piece of crap.
I use images heavily which are all generally loaded by using "UIImageView+WebCache.h" and the SDWebImage package https://github.com/rs/SDWebImage.
I'm just in the process of elimation at the moment as the app never used to run chuggy, but I made a lot of changes in the space of a week which were all intended to make the app smoother and faster.
An example use case is:
User opens App.
Table View loads cells with images and text.
Network call updates data.
User taps tab bar to change to a UICollectionViewController. It reloads.
User taps Profile VC, it refreshes some data.
In Debug... this use case is lightnining fast, transitions smooth and quick on iPhone 4 or 5
In Release mode.. Tapping on the tab bar takes 3 seconds to transition. Scrolling is clunky in the tableview or collection view.
In answer to my own question, the reason was the result of dropping this particular piece of code in my release target.
https://gist.github.com/steipete/5664345
And more precisely this piece of code #define PROPERTY(propName) ##propName:
// Compile-time selector checks.
if DEBUG
define PROPERTY(propName) NSStringFromSelector(#selector(propName))
else
define PROPERTY(propName) ##propName
endif
Was found to be the cause of our problems only discovered by using profiler and realising that it was just soaking up the available CPU cycles. iPhone 4 was so slow it basically was unresponsive.
Anyway, the generic answer is to profile your app to see whats slowing the CPU down.

Black screen on launch, but normal when press home button and enter the app again

As the title, my app will occasionally show a black screen at launch, but I don't know why.
When I press the home button, then entered it again, I saw it was running well. It seems the window could not be made visible randomly. But I don't know when or why does it happen.
You likely don't have a launch image set. When apps are loading their resources they display a launch image, you likely don't have one, which is why you get a black screen.
The reason it doesn't always appear is because if the app is in the background, but still alive, it keeps its resources available for a quick start from the background. It then does not need to display the launch image.
See the Apple documentation
I would say, that there is something wrong with the NavigationController/ViewController stack for Your application. I've had similar situations with exact same problem.
What You can do:
It is pretty hard to suggest something - usually needs tinkering around with the stack structure (maybe try to simplify the stack (remove unnecessary navigationControllers / any tabbarControllers?
Create a separate project, with the same navigationController/ViewController structure, to replicate the problem, upload somewhere, give access to us and we can take a look. But probably - when You will start tinkering around - You will fix the issue Yourself.

Xcode debugging / Instruments: See all pointers to an object

I just started working on a relatively complex project, and have discovered a bug. When the user logs out, the view controllers are still allocated behind the login view controller. They continue responding to rotation events, etc. I have set the controller to nil upon logout, but it's still responding, which indicates that some other object still has a pointer to it. (This project has ARC enabled.)
Pre-ARC I could likely solve this by overriding retain:
- (id) retain
{
// Break here to see who is retaining me.
return [super retain];
}
How can I use the Xcode debugging tools to select an object and list all the other objects that point to it? Is there a better approach than simply hunting through all the code?
As of Xcode 8 you can use the Debug Memory Graph:
Run your app and look at the navigator at the bottom of the screen. You should see a set of three connected circles:
Navigate to wherever so that your object is allocated in memory and then tap on this icon. It should pause your app and a graph should pop up on your Xcode screen. Now, on the left side of the screen you can see a list of objects. Find the object you want to see all the pointers to and click on it. Now they should be visible in the graph. You can expand these branches by tapping on the two arrows on the nodes at the left end of the branch. The graph should look something like this:
This saved me literally days of work. It's an extremely useful tool. I hope it helps someone else too.
The Instruments Heapshot Analysis tool was the best thing I could find for this purpose. This article provides a more complete tutorial, but the basic steps are:
Select Product -> Profile. Choose the Allocations Instrument.
On the left, press the Mark Heap button before/after significant events. In my case, this was before login, after login, and after logout.
Search through the Heapshot for the class you're looking for.
Press the disclosure triangle to see its memory address(es).
Press the arrow to the right of a memory address to see its responsible caller (it appears in the rightmost column.)
If someone else writes up a more thorough explanation, or can offer any related lldb commands, I'm happy to mark your answer as correct.

When the device language changes, backgrounded apps quit themselves

I've observed that if I change the device language, and after coming back to home screen, all background processes quit themselves. If I click on a running app icon again, it starts from scratch -- i.e., from application:didFinishLaunchingWithOptions:.
Am I wrong somewhere? What can I do to work around this?
I think this is a nothing odd and a default behavior.
You may want to look into this post if you want to make changes right from inside your application, though I am not sure on how good this is, as I have not personally implemented it.
language change only after restart on iphone
Let me know if you need more help.
Hope this helps you.

Resources