"Multiple locks on web thread" error thrown inconsistently - objective-c

I'm getting a strange error in my iOS app. The error message is as follows:
bool _WebTryThreadLock(bool), 0x22c820: Multiple locks on web thread not allowed! Please file a bug. Crashing now...
The odd thing is that it happens inconsistently -- sometimes clicking a certain button or textField will cause the crash, and other times the same steps won't cause a crash. I originally had a few UIWebViews in one viewController, but I've commented out everything related to them, so as far as I know, I'm not accessing the web thread at all. Even when I did have these UIWebViews in my project, the error often occurred in viewControllers unrelated to the webView. I also got the error once when my app was open on the device and I received an email. The push notification from the email seemed related. Any ideas what might be causing this?
I am suspicious that this might be related to the way we are currently segueing between viewControllers. We are using modal segues and manually dismissing one viewController upon loading another. Is that a bad idea?
Any input would be greatly appreciated.

Related

iOS - mysterious SIGABRT

I'm getting a SIGABRT - any suggestions how I catch it?
The only clues I have so far are:
the Exception breakpoint (How to track down cause of SIGABRT) does not seem to be catching it
it only crashes on the iPhone 4 device running iOS7 and not on the iPhone 4s simulator or the iPhone 6 device.
Here's my (pretty useless) stack trace:
UPDATE
A longer (but no less useless) stack trace:
Look in the console log. It will provide some info on the error which caused sigabrt. Also be sure to check your outlet and action connections. You may have deleted a outlet after you linked it up and that way xcode can't find that missing outlet you deleted.
SIGABRT occurs when you accidentally/intentionally change connections of an outlet or an action.
According to you, you deleted a connection by merely deleting it from the code but under the hood, it still exists.
So, what you can do is, click on the attribute which is giving the sigabrt and then click on the connections inspector on the right side of the Xcode.
If you see any stray connections, just delete it. This is how you actually delete a connection.
Hope this helps.

Resolving deadlock in iOS app

So I'm trying to convert a project to ARC. The first attempt, I just converted everything and I had this problem on one of my views, it just hangs. I cannot click on any UI element, and nothing is printed to the console, and it doesn't crash. It just sits there.
So in order to start troubleshooting it, I converted all the simple classes and viewControllers, and then for some of the more complex model classes and UIViewController classes, I set the compiler flag for -fno-objc-arc. My app runs better, but it still just gets in this state where it hangs. I've never seen this on it prior to converting to ARC. I was wondering if anyone else has had this problem and what I can do to troubleshoot it. Thanks~
I would press "pause" in the debugger and look at the call stacks for all threads in your app. This can point out why your app is locked up.

Application crashes while logging out in iPAD

My question is specific to iPAD, and I also aware of the basic memory management of iOS, but I am having a different problem.
As I have build an application where I have several UIViewControllers and UIViews,
I have a loginController thats gets called when I launch the App.
My MainView is a single screen with all the ViewController loaded and placed at their respective places and the app runs fine and smoothly.
Problem:
Problem comes when I logout, most of the time my App crashes by saying EXC_BAD on the
[super dealloc] line of my mainView controller.
As for now on I have added a custom function cleanUP in all my viewControllers that gets called when user logout from the app.
Is this the right approach ?
As I know that we can clean up in our didload etc. function and the dealloc gets called too.
but here i have an iPAD when my all viewControllers are just open in front of me, They will be closed or not visible when I logout from the App.
So how to approach on my crash issue and How to manage memory here in my iPAD?
The best way I know to resolve bad-access problems is to use Instruments with the Zombie tool. As you probably know, when you get a bad access issue, is because you try to access to an object that is deallocated.
Try go to Product -> Profile and choose Zombie. Hit record and reproduce your crash. then inspect the pointer to the object that produced that crash and look for the retain count.

Facebook Connect Login Dialog crashing app

Of the many problems I've been having with my current app, this is one of the most annoying.
In the simulator the login dialog works fine, however on a device it's just a frozen white box and the console prints the following:
void SendDelegateMessage(NSInvocation*): delegate
(webView:resource:willSendRequest:redirectResponse:fromDataSource:)
failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
I've looked this up but I'm still not sure what it means.
If I try switching
[self authorizeWithFBAppAuth:NO safariAuth:NO];
to
[self authorizeWithFBAppAuth:NO safariAuth:YES];
it switches to the safari app to verify but this somehow kills my app with an error which says ReturnNotPermittedKillClient.
Has anyone experienced a similar problem? On my last app it just worked without any of these issues, and as far as I can see I've done everything the same way this time. However this project was inherited from someone else so there may be underlying causes that I am not aware of.
Edit: Just tried moving the login request from didFinishLaunchingWithOptions to a point in the intro screen class where everything else has already been loaded, just in case it was a memory issue caused by too many tasks trying to run at the same time. This time the error message didn't appear, however the login box still remained white and then closed the app a few seconds later.
Edit2: Seems like it's simply a memory error. I changed all variables which I had previously released to be retained, which has fixed the problem on my 3GS. However on my iPad 1 the problem persists. Incidentally, when changing shouldAutorotateToInterfaceOrientation from using landscaperight to using landscaperight or landscapeleft, when I rotate the iPad I get a memory warning and then the same crash. In both cases there are no debug error messages other than the memory warning, and the app just closes down - there is no breakpoint etc to see where the issue lies.
if you are using the webview then we need to do this first b4 moving to next view .delegate = nil;
This might be what you want:
There are other branches of this in NSObject in the documentation.
Code:
[self performSelector: withObject: afterDelay: ]
The problem was simply down to memory. After changing the way it loads images, sounds etc the problem has gone away.

Time limit for an IBAction?

It may sound as a dumb question. In fact, I am still thinking if that might be the cause but working with XCode and having set iOS 4.3 as my Deployment Target and iPad as my Device I am getting an unexpected error.
While running my app through the Simulator I can get it working. But when I run it through my iPad a single IBAction, fired when user taps an UIButton, that takes almost 4 minutes is not completing. In fact it's getting stopped at the same point, in a for loop.
I searched for memory leaks using XCode and it didn't find any, therefore I'm asking if there's a time limit for IBActions. I read there are 10 minutes limit for methods in background but I didn't find anything related to IBActions in foreground yet.
I think the user gets tired of waiting for a response long before the system. Normally, a button press or similar should finish after one second at most (well, maybe 1.5s), or the user thinks that the system is "slow".
I would make sure that you have your button outlets properly hooked up. It is possible that it just isn't throwing the exception so you get a slow system. Put NSLog displays in your IBAction method and make sure it is executing it properly. You should be able to track it back to figure out what is going on.