QuickBlox: EXC_BAD_ACCESS for QBChat methods on iOS 8 - quickblox

Sometimes the request made by QBChat (retrieve dialog list, chat message history, send message...) cause the app to crash.
When I traced back, the EXC_BAD_ACCESS occur in [EndpointsAPIStorage retrieveEndPoint] called in [QBQuery performInBgAsyncWithDelegate].
Does anyone have any idea about this?

Related

"Multiple locks on web thread" error thrown inconsistently

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.

unrecognized selector sent to instance on deviceOrientationDidChange

Right now my app should only supports Portrait. On Summary/Supported Device Orientations I have only selected Portrait so I'm hoping that my app will not rotate. I was testing the app on a device and suddenly I'm getting the following error randomly:
[UIButtonContent deviceOrientationDidChange:]: unrecognized selector sent to instance
It happens when I rotate the device SOMETIMES, is not consistent, and is not always over UIBUttonContent. I supposed that if I only select Portrait, deviceOrientationDidChange should not be called or should be ignored.
Other times my app crashes with an EXC_BAD_ACCESS (code=1, address=something) but it happens when I rotate the device so I'm guessing that both errors are related.
I don't know what to do with this, it's hard to debug because I don't have feedback, the All Exceptions Breakpoint is not being called, so I don't know where and exactly why this is happening. Any idea on how to debug this is welcome.
These are the classic signs of a memory management error. You have over-released some object and it has been deallocated while something else still references it. Later, something messages it. In some cases a new object has taken its place, but that object doesn't understand the messages it's receiving. In other cases, there's no valid object and you get a crash.
Edited to second the advice to use the Zombies instrument to find the over-release.
Do you have a class that should be called with deviceOrientationDidChange:? When this happens, it usually means that you have a dangling reference to a deallocated object. You should try profiling your app with Instruments in "Zombies" mode.
I solved this issue a long time ago, but I think is good to share what actually helped me on this case.
After trying everything with no results with Instruments I started debugging old-school. I had an idea of "where" the error was so I just commented all the code on that section. I was right, the bug just disappeared along with some functionalities. After that I made "binary uncommenting" (uncomment one half) till I got the bug line. It was a third party library, I had an object that was not being released properly.

Reasons for MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification

The documentation for MFMessageComposeViewController says you should check [MFMessageComposeViewController canSendText] before trying to create a MFMessageComposeViewController.
It also says:
in iOS 5.0 or later, you should register as an observer of the MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification notification to be notified of changes in the availability of sending text messages.
What possible reasons could there be for the availability of text messaging changing?
Is it just to make Linus Torvalds cry?
Background: I’m creating an iOS app that requires the ability to send SMS messages. I’ve added sms to UIRequiredDeviceCapabilities in Info.plist. It should only run on iPhones (according to Apple docs, I read somewhere this does not include iPod touches or iPads solely with iMessage)
If text messaging is not available, the app is useless, and should present some useful error message.
Update: I’ve tested with my iPhone 4S that simply having a locked SIM still returns YES from canSendText – still not a reason for message sending ability to change.
Update #2: I have created a simple test app to see what might cause it. I have not received the notification at all.
Things that don’t cause MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification
Turning iMessage on & off
Losing WiFi connectivity
Turning on airplane mode
Locking iPhone SIM card
Things that can cause canSendText to change between YES/NO (but not send a notification)
Turning iMessage on & off on an iPad (I assume iPod touch too)
I’m guessing the correct case is for iPads and iPod touches when iMessage is turned on or off, however, there must be a bug (either in my test code or Apple’s) that’s preventing this from working.
If you need this notification, I tried just checking [MFMessageComposeViewController canSendText] again on UIApplicationDidBecomeActiveNotification. This sometimes works, but if you switch quickly between Settings.app and your app, it may not have changed yet by the time you switch to your app, causing canSendText to still reflect the old value.
My solution for now is just going to be simply checking canSendText just before relevant decisions are made, and handle the (rare?) case where it may have changed without me knowing in some appropriate way.
Since MFMessageComposeViewController can use iMessage in iOS5, I'm guessing it's probably to handle the case where iPod Touches and Wi-fi iPads lose internet connectivity while a message is being typed.
I managed to rule out another scenario where it does not trigger MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification.
Sender iPad with a working wifi connection
Reciepient Android phone
Result: MessageComposeResult == MessageComposeResultSent, MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification was not triggered
Next I tried the same scenario with iMessage in order to duplicate the final results. (== not being able to send an iMessage).
Then I realized that iMessage was able to tell me in advance this would never work by putting a red exclamation next to the recipients name with the message this person is not registered with iMessage. The MFMessageComposeViewController does not do this!!!
My current conclusion is: canSendText should be named canComposeText.
MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification does nothing.
Currently, there is no case where MFMessageComposeViewControllerTextMessageAvailabilityDidChangeNotification is sent.
The only time when the value of canSendText changes is when iMessage is turned on/off on an iPad or iPod Touch (not an iPhone, which has SMS messaging).
Even when canSendText changes, no notification is sent.
(Unless it’s just a bug in my test code?) This appears to be a bug or missing feature in Apple’s code.

iPad crash after fast restart, when performing task at exit

I'm working on an iPad app, targeting iOS 3.2 (so everyone can run it), and when the user presses the Home button, the app gets an applicationWillTerminate: message and it sends usage data to a server before it exits.
This all works fine. But if you exit and then restart the app before it's done exiting, it appears to crash.
The 5 seconds you get to clean up when the app is exiting begins once you get the applicationWillTerminate: message, but the app disappears immediately from the device, giving the user the opportunity to launch it again.
I think what's happening, is that they're just reactivating the app before it's done exiting, and so they're just jumping back into the first instance of the app just before it actually exits. So the second instance of the app appears to be crashing.
There is no crash log, and putting a log message into the application:didFinishLaunchingWithOptions: doesn't produce any logs in the console from that second launching of the app. This is why I'm pretty sure it's not actually creating a second instance but just re-entering the first instance which is almost done exiting.
So are there any ideas out there about how to avoid this situation? It seems odd that you are given 5 seconds to perform actions on exit, but then this odd behaviour happens as a result.
I'm worried part of the problem is that the app is targeting iOS 3.2 and is actually exiting when the HOME button is pressed, and if it were just going into the background, this wouldn't be an issue. Sadly, changing that behaviour is just not an option at this moment.

[UIImageView _isChargeEnabled]: message sent to deallocated instance

I am getting this error message from an apparently private API. Anyone have a clue what this could be? It seems to occur, if you use MPMoviePlayerViewController and do a pinch while the movie is running. This will close the player, but afterwards the app crashes.
Only seems to be a problem with certain version of iOS (in this case iOS 3.2.2 on an iPad).
I found one post in another forum, but that did not really help, as with MPMoviePlayerController a different problem occurs.
FWIW, the issue is not the private API, it's that you've got a zombie object.