Omniture App Measurement for iphone getting issue when app goes background - iphone

To Implement the Omniture Tracking in an iPhone Application, I have downloaded the AppMeasurement software from SiteCatalyst(AppMeasurement.h,libAppMeasurement.a,libAppMeasurementNoThumb.a).
I am using Omniture's app measurement iphone library, linked the release and dev libraries. I instantiate them using the singleton method (getInstance). Implemented as below
#import "OmnitureTracking.h"
#import "AppMeasurement.h"
AppMeasurement *s = nil;
#implementation OmnitureTracking
+ (void)beginTracking {
s = [[AppMeasurement getInstance] retain];
s.account = #"";
s.debugTracking = YES;
}
Calling this 'beginTracking' in AppDelegate to initiate the tracking, for pagetracking implemented another method as below:
+ (void)trackViewForPage:(NSString *)pageName {
NSLog(#"trackViewForPage::s instance::%#::",s);
if (s == nil)
return;
[s clearVars];
[s track:[NSDictionary dictionaryWithObjectsAndKeys:pageName, #"pageName", nil]];
}
Implementaion working fine and getting below log:
2012-06-21 01:53:20.953 MyApp[857:607] App Measurement Library compile time = Aug 4 2011 16:29:52
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
2012-06-21 01:53:21.795 MyApp[857:607]
Omniture App Measurement Debug: http://MyApp.net/b/ss/MyAppiosappdev/0/OIP-2.1.2/s2253418?AQB=1&ndh=1&t=21/5/2012%205%3A53%3A20%204%20240&vid=01398194867219045&ce=UTF-8&pageName=MyApp%201.2%20%281.2%29%20Launch&ts=2362139876678&events=event7%2Cevent5&c1=D%3Dv2&c2=D%3Dv6&c3=D%3Dv11&v2=MyApp%201.2%20%281.2%29&v4=0&v5=0&v6=20&v7=5&v8=Thursday&v9=4.3.3&v12=D%3Dv3&v13=D%3Dv3&s=320x480&c=24&AQE=1
But when app goes background and enters foreground, app is crashing because of Tracking and getting the log as below:
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::(
""
)::
Jun 21 03:07:41 unknown MyApp[467] <Error>: -[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0
Jun 21 03:07:41 unknown MyApp[467] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0'
"AppMeasurement" instance becoming nil or empty when app goes background and enters foreground, but I am not able to figure out whether its the Site Analyst iPhone Library issue or Coding issue.
To handle the crash,I have done the nil check, but its not falling under nil case.
Please help me in figuring out the "AppMeasurement" instance empty check and why "AppMeasurement" instance becoming empty when app goes background and enters foreground.
Thanks

Finally, i have figured out the things. Sorry for all the mishap.
All I am doing is using a 3rd party library to implement the Omniture Tracking for iPhone Application which is provided by Site Catalyst itself.
Please refer the below URL for library :
Site Catalyst Omniture library is intended for apps developed for all iOS devices, including iPhone, iPad and iPod Touch
There is problem with the library itself, its having lot of memory management issues.
They have provided new library with the memory leakage fixes.
Uploaded the new libraries to fix the issue.
Got the issue at the supporting class - OmnitureTracking.m, while setting the AppMeasurement.h Property :
//Use best practices plugin
s.useBestPractices = YES;
Because of this property, omniture tracking got called whenever app comes to active state i.e. launches. As the libaries having memory management issue, app getting crashed when ever app goes background and comes foreground.
Thanks for the replies.
But still one thing haunting me is how to check the empty instance of a class
If instance is there, its getting on NSLog as
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
But in error case getting the instance on NSLog as
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::("")::
By seeing that , i am thinking it as EMPTY INSTANCE case. How to check this case? Its not checking under nil check.

That code is a mess; hard to say what is wrong for the reasons mentioned in the comments on your question.
no method should be prefixed with get unless it is of a very special type
beginTracking leaks whatever is assigned to s
So... s is being assigned to an NSArray instance either because the poorly named getInstance is returning an NSArray or you are over-releasing that object.

Related

How to fix loadPersistentStores from crashing on load

I'm trying to develop an app on Xcode that uses core data, however, when I submit the app for test review it crashes on their simulators, but not mine. What's going on here?
For starters, I've recently finished making an app that took a while to develop and went to submit it to iTunes connect. My App was rejected because "we were unable to review your app as it has crashed on launch". I received and symbolicated the line where the crash happens.
https://imgur.com/a/3iX6pqc
The crash happens on line 81 in my App Delegate exactly where I go to get my persistent container and load it in.
https://imgur.com/EzQvnSQ
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "AlarmSavedData")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
print("Here!")
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
I expected that the local database would load in just fine for them, but for some reason, I'm the only one that the database loads in for. I'm able to use it but when the Apple Review team tries to run it, it crashes. Any ideas on what's happening and to do to fix it? The goal is for every user to have their own local database using core data to store their created data.
Crash Log : https://imgur.com/a/rx9doSR
Try resetting the simulator. That fixed it for me:
First of all, ensure that you are testing your app with a simulator of iOS 12.1.4 as indicated in the crash report. The crash report indicates the Hardware to be 1xxx which is apparently some kind of placeholder, not helpful.
I can't explain the crash yet, but here are some clues that might help you find it.
In Apple's TN2151, regarding the EXC_BREAKPOINT type of crash which is what you have, it is stated:
Swift code will terminate with this exception type if an unexpected condition is encountered at runtime such as:
a non-optional type with a nil value
a failed forced type conversion
Putting this together with the fact that the crash occurs in loadPersistentStores() implies that maybe it is not crashing for you because you already have a persistent store on the simulator's simulated disk – that is, you are not a first-time user. App Review is, of course, a first-time user. So you should remove your app's data, in particular the persistent store file(s), from the simulator and test again. Now your test will be more like App Review's.
You should also probably read this answer which discusses a somewhat similar situation.

iOS Bluetooth Programming - Trouble establishing p2p between two iPad's

Im sorta new to bluetooth programming on the iPhone and i wanted to set up a PeerToPeer bluetooth connectivity between two iOS devices. I followed the steps in this tutorial
http://www.devx.com/wireless/Article/43502/0/page/1
and everything happens as it should until i get the accept or decline option when another device has been detected.
As soon as i choose accept, the app crashes on BOTH devices. And the error message shown is this:-
wait_fences: failed to receive reply: 10004003
2012-03-05 15:40:25.809 Bluetooth[204:707] -[ViewController session:didFailWithError:]: unrecognized selector sent to instance 0x367fe0
2012-03-05 15:40:25.811 Bluetooth[204:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController session:didFailWithError:]: unrecognized selector sent to instance 0x367fe0'
Anybody know whats going on?
Thanks in advance!
Just copy pasting this from coments below in the link you posted:
In case people weren't able to build and run successfully, you need to import the GameKit framework (rightclick frameworks folder > existing frameworks > GameKit.framework)
Add, to the BluetoothViewController.h file:
#import "GameKit/GKSession.h"
#import "GameKit/GKPeerPickerController.h"
Found out the problem. Made a rather silly mistake!
Ive written a method as follows
- (void)peerPickerController:(GKPeerPickerController *)picker
didConnectPeer:(NSString *)peerID
toSession:(GKSession *) session {
and in it i set up the app to receive data via bluetooth using
[session setDataReceiveHandler:self withContext:nil];
I thought i would check if the connection is established first and then think about the data transfer. But turns out you can't do that coz the data handler has been set and i had not implemented it in self. When i did write that though, it worked fine!
Hope, this stope people from committing such obvious mistakes!

memory leak - application exited with signal 9

I have an application which is dealing with many data structures, uiimageviews, videos, creating bit map context and so on. Every time the application is crashing on its continuous usage for a long time. The application is crashing with the memory warning --> Application exited abnormally with signal 9. What may be its reason. What does signal 9 means.
I think this is due to the memory issue. Your app is using lot of memory due that is app is killed..
Check out this posting
http://lists.apple.com/archives/xcode-users/2011/Mar/msg00837.html
It sounds like it might be related.
It can also be a privacy/permission issue.
We forgot to add NSCameraUsageDescription and UILaunchStoryboardName to Info.plist file and our app crashed with error Message from debugger: Terminated due to signal 9
After adding the following lines to Info.plist the app sopped crashing.
<key>NSCameraUsageDescription</key>
<string>The app would like to let you make a picture.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>The app would like to let you choose an item from your Photos.</string>

Creating a bug report from when the app crashes on the phones of testers?

I'm wanting to have a bunch of people beta test my app on their phones soon. In the event that the app crashes, what's the best way for them to send me a bug report?
A good approach is to use a 3rd party service like Instabug which is a bug & crash reporting service that allows for two things:
Automatically receive crash reports in the event of a crash
Allow users to report bugs through a shake gesture in-app.
All reports arrive to your Instabug dashboard containing various details such as:
Network and console logs
Complete Device details
Visual reproduction steps
3D inspection of the current view hierarchy
Crash stack trace (In case of a crash report)
It only takes a line of code to integrate.
For full disclosure, I work at Instabug. Let me know if I can help.
My own experience: I used Flurry as the analytics tool in my project. I followed Flurry's recommendation and set up an uncaught exception listener inside my code.
void uncaughtExceptionHandler(NSException *exception) {
[FlurryAPI logError:#"Uncaught" message:#"Crash!" exception:exception];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[FlurryAPI startSession:#"my_API_here"];
....
}
And then I tested my app, and after several hours' delay, I was able to see a few crashes reported to Flurry. Things like this:
NSInvalidArgumentException:
-[NSCFString objectAtIndex:]: unrecognized selector sent to instance
0x2e1b30 Msg: Crash!
It's neither complete nor thorough, but it was a convenient way to have a basic sense of what's going on out there in the wild.
Setup a database for it. Have a submit form that places their report into the database. This way any of the info they submit can be searched and managed easilly.

iAd strange console "Unhandled error"

I'm seeing in the console:
"Unhandled error (no delegate or
delegate does not implement
didFailToReceiveAdWithError:):"
Although didFailToReceiveAdWithError is being invoked (I can see that with check points and in the console log)
Does someone has any reasonable explanation? It's like it's working and not working all in the same time. I'm not using IB for the adview, and have added it programmatically and have set the adview.delegate = self. I'm also using three20 in this project if that changes anything.
It's like sometimes he knows who's his delegate and sometime not...
The Apple documentation says:
While you are developing your application, iAd Network sends test advertisements to your application. To assist you in validating your implementation, the iAd Network occasionally returns errors to test your error handling code.
In my app iAd also returns a mix of correct banners, error 3, error 5, ... and so on. Maybe this problem will disappear after the release of the app when iAd changes from
iAd Network serves test ads
to
iAd Network serves live ads if you signed the iAd Network Agreement and enabled advertising for your application