iOS 5 - app runs fine, iOS 4 - hangs on [UIWebView alloc] - iphone

I am testing backward compatibility of an app before submitting it to the app store.
iOS 5 devices run the app great, but now I'm testing on an old iPod touch with iOS 4.2.1.
What Goes Wrong:
At one point (always the same point), the app just hangs - it doesn't crash, just freezes so I'm thinking it's not a lack of memory causing it.
No errors are displayed, however following the code by setting breakpoints results in this line:
myWebView = [[UIWebView alloc] initWithFrame:webFrame];
running but never finishing.
So:
What might be going wrong, what can I do to further get more info/logs about what may be happening? Any ideas are much appreciated, thanks!

Make sure that you don't have duplicate entries like instance variable and property for "_myWebView" and "myWebView". Try to use _myWebView.
Try to remove assignment statement and see if it works then problem is duplicating ivar and property.

Related

App crashes on iPhone but not simulator or iPad?

I have developed an app for the iPhone and everything is going well. Today i decided to prep it for the upcoming iOS 7 launch, and the app worked as intended until I tried it on my iPhone 5. Whenever it crashes it throws some exc_bad_access codes.
It doesn't crash in the simulator or on my iPad which is running iOS 6.1.
I hope you guys can help me.
Btw, i get different exc_bad_access codes every time, but this is one of them.
http://gyazo.com/43716488eb120e44e74f76cd4d659076
You have thread-related race conditions. Note how it's crashing in thread 7? Race conditions will express themselves differently on different hardware since the timing can be dramatically different.
tableView:cellForRowAtIndexPath: is a UIKit method that must run on the main thread. In your case, it's running on thread 7, which is itself probably the cause of your problem. I suspect you're doing something like calling reloadData on a background thread.
Note that you're also directly accessing your ivars rather than using accessors. That tends to make threading problems harder to track down and manage. You should always be using accessors except in init, inside of accessors, and in dealloc.

ADBannerContentSizePortrait not available on iOS 5

I am adding the iAd framework to an existing application. The application is portrait only and iPhone only. Everything is running in iOS 6, both in the simulator and on an iPhone 5. However, it fails in iOS 5 both in the simulator and on an iPhone 4. It throws the following exception:
'NSInternalInconsistencyException', reason: 'currentContentSize must be one of the requiredContentSizes; 'ADBannerContentSizePortrait' is not in {(
ADBannerContentSizeLandscape
)}'
The exception is thrown on this line:
iAdBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
I see no way of displaying anything other than a landscape banner this way. I'm assuming I must have something configured wrong somewhere, but I don't know where, and find it curious that it works fine in iOS 6.
Any help here is greatly appreciated! Thanks!
UPDATE: I can't answer this because I don't have enough rep points. But I have it fixed:
Background: I'm using the Kobold2D wrapper around ADBannerView. It's class, KKAdBanner, is the one that is actually calling the line causing the error. It turns out, it was preceding this call by configuring ADBannerView to only allow landscape sizes. This was a configuration issue and I can resolve it.
Of course, now I don't know why in the world it ever worked in iOS 6 at all, but oh well :-)
I've never used this, but from what I'm understanding from the documentation you need to set the #property(nonatomic, copy) NSSet *requiredContentSizeIdentifiers
with all the value that currentContentSizeIdentifier could take.
And your exception is saying that in that NSSet you only have the one for the landscape.
The difference you are seeing could be due to a different default values in different iOS version. (I'm guessing)
Reference here.

App crash only on iPhone Device and not in Simulator

In my app, when I press a button the method called for that button first assigns my textfield texts directly to NSArray object like:
val = [[NSArray alloc] initWithObjects: nameText.text, cellText.text, p_emText.text,
p_cnfrmText.text, s_emText.text, s_cnfrmText.text,
emailText.text, ecnfrmText.text, lat, longt,
nil];
when I run my app on simulator no app crashing occurs, but when I run it on my iPhone device it gives: Thread 1: program recieved signal "EXC_BAC_ACCESS"
Can anybody tell why this happens and what's the solution for this scenario?
In XCode, go to menu "edit scheme", choose the running configuration and add 'NSZombieEnabled' like in the picture below, when your apps crashes, it will provide you additional infos on the crash that should help you debug it.
EDIT
Note that when your application debug is over, remove the NSZombieEnabled command as it impacts the application performances
All objects involved in array creation using initWithObjects should be actual objects. There is no enough code in your question to know if lat and longt are objects too. Are they?
If they aren't, wrap them with [NSNumber numberWithFloa:<# the float #>].
If that's not the problem, check SO questions regarding EXC_BAC_ACCESS to learn to debug them.
Delete the app from simulator/ delete the build file from Mac/ clean the product from XCode and then again run it in simulator. Check if it crashes in simulator now.
Take a look at this link : EXC_BAD_ACCESS signal received. Also, Take NSLog of all the textfield.texts before putting them in array. May be one of them has become nil.
it may be a case of memory managemnet...have you released all the objects after their use?
simulator has the memory space of whole of the machine...but iphone has a defined memory of a sandbox for a single app.
Most probably your app is crashing due to memory issues since it is not crashing in simulator, try to release all objects that you allocate at the points you are done with them.
If you have your custom objects which you allocate and initialize as;
MyCustomClass *myObject = [[MyCustomClass alloc] init];
you need to release them as
[myObject release];
especially if they have members which are assigned big sized images or other kind of data.
If your app starts to crash less after you start solving these memory management issues, it shows that you are on the right way. So keep releasing.

Flurry API crashing iPhone simulator

My app is crashing using iOS5 and iOS4.3 iPhone simulators in Xcode 4.2, the stack trace shows BAD_ACCESS signal in [FlurryAPI stopBackgroundTask] method.
While in the iOS4.3 simulator the app is only crashing when sending the app to background, in iOS5 is crashing always.I am attaching a picture of the debug navigator showing the thread where the BAD_ACCESS is happening.
On the other hand the app is working fine using a real device.
Any ideas of how can I get more information of what is going on and why this is happening?
I've worked around this issue by adding the following to didFinishLaunchingWithOptions
#if TARGET_IPHONE_SIMULATOR
[FlurryAnalytics setSessionReportsOnPauseEnabled:NO];
#endif
Flurry analytics does not run other than main Thread. It might crash on background thread.
It looks like you have a zombie - you have a situation where you're using code after you've released it. The retain count reaches zero, so the system dealloctes and re-uses the memory, then you make a change through the original reference. Now you have two different references to the same memory, each of which expects a different object to be there. In your case, one of the references is within flurry.
The reason for your device/simulator differences is the different memory allocation schemes the two architectures use - the simulator seems to re-use memory very aggressively.
Enable NSZombie and run in the debugger. If you're lucky, it will give you the object and the point it's used after deallocation.
Enable NSZombie: Menu 'Product', 'Edit Scheme...' 'Run' page, 'Diagnostics' tab, tick 'Enable Zombie Objects'.

ipad / iphone application EXC_BAD_ACCESS only in simulator, not on device

I was at client site today and made a couple of bug fixes there and then. I deployed the working copies of the app to their iPads and iPhone. Perfect. I have come home and now run the app in the Simulator.... but it crashes each time and I cannot figure out how. Unfortunately, I cannot see what I have changed which would cause this.
Does anyone know why you'd see the error message Program received signal: “EXC_BAD_ACCESS” on the simulator and not the iPad or iPhone?
I'm using Xcode 3.2.4 with OS4.1 on the iPhone 3GS and iPad 3.2.2 running on OSX 10.6.4
Thanks for any information. I'm tearing my hair out....!
[update]
here's the code where it's failing
- (void)dealloc
{
if (_node)
{
if (_node->_private == self) //THIS IS THE LINE that debug is stopping on
_node->_private = NULL;
_node = NULL;
}
//
[super dealloc];
}
IS there any chance that this object isnt being retained properly? The Simulators memory is reused very quickly, thus if a pointer's retain count becomes 0, it will remap quickly and on the next access things can blow up.... reuse of memory in my experience is slower on the devices. Depending on the object;s type you can use CFGetRetainCount or [_node->_private retainCount];. If the object still breaks there isnt one.
That _node is used strangely. From your use of -> it appears to be a pointer. But you then set it to NULL. That's a very odd way to free a pointer or remove a reference to it.
Are you freeing the _node elsewhere? Maybe _node is being freed before this is called. That would give you a problem when you try to work with it.