Log in or register to post comments

UserDefinedTargets inside UINavigationController

April 7, 2013 - 8:53am #1

Hi all!

 

My starting point:

- vuforia-sdk-ios-2-0-31

- UserDefinedTargets-2-0-7

 

I've tried to customize the UserDefinedTargets example with ARC, storyboard and UINavigationController. All works fine the first AR-flow, but when I come back, not immediately, but at some point the application crashes.

I've read many post regarding this in this forum, as these:

https://developer.vuforia.com/forum/ios/qcar-inside-uinavigationcontroller

https://developer.vuforia.com/forum/ios/integrating-sample-codes-tabbed-application

https://developer.vuforia.com/forum/ios/black-screen-after-pushing-view-my-custom-viewcontroller-arparentviewcontroller

However, I've not found the solution.

changed the AppDelegate to the storyboard-based style.

I only use storyboard for my stuff. I have a DetailViewController where I push to AR-flow:

 

DetailViewController.h

 

...

@class UDTParentViewController;

 

@interface DetailViewController : UIViewController 

 

@property (weaknonatomicIBOutlet UIImageView *imageView;

@property (strongnonatomicNSString *urlImage;

@property (strongnonatomicUDTParentViewController *udtViewController;

 

- (IBAction)test:(id)sender;

 

@end

 

DetailViewController.m

 

#import "DetailViewController.h"

 

@interface DetailViewController ()

 

@end

 

@implementation DetailViewController

 

@synthesize urlImage, imageView, udtViewController;

 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}

 

- (void)viewDidLoad

{

    [super viewDidLoad];

          // Personal code

 

    udtViewController = [[UDTParentViewController alloc] initWithNibName:nil bundle:nil];

    udtViewController.arViewRect = self.view.bounds;

 

}

 

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

- (void)viewDidUnload {

    [self setImageView:nil];

    [super viewDidUnload];

}

 

- (IBAction)test:(id)sender {

    [self.navigationController pushViewController:udtViewController animated:YES];

}

 

 

@end

 
I think that the problem may be related to memory leaks.

Can anyone help me?

Thanks in advance!!

 

 

 

 

UserDefinedTargets inside UINavigationController

May 2, 2013 - 2:47am #17

Glad you found a solution, and many thanks for sharing :)

N

UserDefinedTargets inside UINavigationController

May 1, 2013 - 11:47am #16

 

Hi all!
 
Finally, I solved my main issue with Danchoy's recipe. I have implemented it step by step, following what he wrote in this post https://developer.vuforia.com/forum/ios/qcar-inside-uinavigationcontroller#comment-2016033
 
To solve the problem with the orientation (turning the phone to landscape), I commented the following lines of code in UDTParentViewController.mm:
 
In loadView method..
 
 
 /*
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationDidChange:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
*/

 

jomavifi

 

UserDefinedTargets inside UINavigationController

April 16, 2013 - 4:51am #15

Thank you!

If I find the way to solve this issue, I will share it in this post.

Also, I'm hearing all kinds of proposals to solve this.

 

jomavifi

UserDefinedTargets inside UINavigationController

April 16, 2013 - 2:25am #14

I don't think you can at the moment, because if you do try to init/deinit then it will most likely crash.

However, one thing you could try is Danchoy's suggestion that was posted on 24th September 2012 in this thread

https://developer.vuforia.com/forum/ios/qcar-inside-uinavigationcontroller

This shows an alternative way of destroying the AR which may help you.

 

N

UserDefinedTargets inside UINavigationController

April 16, 2013 - 12:53am #13

 

Hi NalinS,

I will try with your suggestion.

However, I'm thinking about destroying the AR-flow when I go back. So I always create the AR-flow when I press the button.

How I could destroy the flow programmatically in this situation?

Thanks for your help!

jomavifi

UserDefinedTargets inside UINavigationController

April 15, 2013 - 11:21am #12

Ok, I tried this and after a few times going back and forth it did crash.

The main reason I can think of for this is that the ViewController that is creating the AR eventually gets unloaded (when iOS decides) and that's why it tries to deactivate the dataset.

The solution here would be to create the AR as a singleton to be sure it is created only once.  Not ideal perhaps, but it ought to work.

 

N

UserDefinedTargets inside UINavigationController

April 15, 2013 - 10:42am #11

Hi NalinS,

I attached my storyboard too. In the picture, you can see the flow that I mentioned earlier. 

My DetailViewController is your StartViewController. Try to add another VC that does nothing. It just has a button to go to the other VC (your StartViewController). With this flow the app crashes :(

 

jomavifi

UserDefinedTargets inside UINavigationController

April 15, 2013 - 5:40am #10

My storyboard is the one attached.

HTH

N

UserDefinedTargets inside UINavigationController

April 15, 2013 - 4:06am #9

I think I have not explained well. I mean a VC before that VC. 

The InitialVC (embedded in UINavigationController) only have a button to push by segue to this VC (your StartViewController). Now, in this StartViewController, I have your code with the button to push by code:

    [self.navigationController pushViewController:_cameraViewController animated:YES];

When I say "the first time go back" I want to say one go-back to StartViewController. Then I go back to InitialVC pressing the button again to return.

 

jomavifi

UserDefinedTargets inside UINavigationController

April 15, 2013 - 3:45am #8

I think that if you add a previous ViewController, you will get the same crash log.

Not true, because that is exactly what I did below.

 

This line creates it once, and once only:

   _cameraViewController = [[UDTParentViewController allocinitWithNibName:nil bundle:nil];

 

...and this line pushes this existing VC rather than using a segue (which always tries to create a new one):

    [self.navigationController pushViewController:_cameraViewController animated:YES];

 

HTH

N

UserDefinedTargets inside UINavigationController

April 15, 2013 - 3:27am #7

Hi NalinS,

Thank you for your suggestion!

After writing the previous post, I did tests with a clean UDT and clean Storyboard. One ViewController embedded in UINavigationController and one button to push AR-flow by code, as you told me in your previous post. All works fine.

The problem comes when you introduce a new ViewController. The full flow is as follow:

InitialViewController with button connected by segue to DetailViewController. In the DetailViewController, I have a button to push AR-flow by code (like the initial case). When I go back first time (return to DetailViewController), all OK. When I go back other time (return to InitialViewController) the app crashes (all this with clean UDT and clean Storyboard). I get always this log:

 

QCARutils onDestroy()

Invalid request to deactivate data set.

(lldb)

 

I think that if you add a previous ViewController, you will get the same crash log.

 

In conclusion, I think that I need call onDestroy method manually in the first go-back, but I don't know how to implement this in the code.

 

Thanks for your patience!

 

jomavifi

UserDefinedTargets inside UINavigationController

April 15, 2013 - 2:31am #6

My suggestion is this.

Try the code and modifications I detailed below on a fresh sample of UDT to prove whether you can get it working without any crash as I did.

Next, assuming it works ok, compare in detail with your own code to identify where it is different and where the problem might be.

 

HTH

N

UserDefinedTargets inside UINavigationController

April 15, 2013 - 2:16am #5

 

Hi NalinS,

One more time, thank you for your reply!

You're right!

In this case, when I go back to the DetailViewController and I push the button again, the AR-view is black instead of the camera view.

 

My problem of screen black is due to an old code that I should have fixed. Now is OK. When I go back, the AR-flow calls onPause() method and when I push the button again, onResume() method is called.

 

But my main concern is the other case, when I go back two times (I have two ViewController before AR-flow, InitialViewController -> DetailViewController -> AR-flow).

When I go back the first time, I get this log:

2013-04-14 17:31:42.469 UserDefinedTargets[1027:707] ARParentVC: dissappeared

2013-04-14 17:31:42.470 UserDefinedTargets[1027:707] ARVC: viewDidDisappear

2013-04-14 17:31:42.470 UserDefinedTargets[1027:707] QCARutils onPause()

2013-04-14 17:31:42.471 UserDefinedTargets[1027:707] APPSTATUS_CAMERA_STOPPED

2013-04-14 17:31:42.775 UserDefinedTargets[1027:707] ARVC: viewDidDisappear

 

All OK, it’s as the other case.

When I go back the second time (I return to the InitialViewController), I get this other log and the app crash:

2013-04-14 17:33:53.270 UserDefinedTargets[1027:707] QCARutils onDestroy()

2013-04-14 17:33:53.270 UserDefinedTargets[1027:707] Invalid request to deactivate data set.

(lldb)

 

This case is described in the previous post: “Other case with the same code: when I go back to the DetailViewController, and I go back to other ViewController (InitialViewController)...

 

Other log with the same conditions. In this case, In this case, the application didn't crashed yet. I went to DetailViewController and I push the button to AR-flow:

 

2013-04-14 17:36:15.274 UserDefinedTargets[1044:707] ARVC: viewDidDisappear

2013-04-14 17:36:27.753 UserDefinedTargets[1044:707] QCARutils onDestroy()

2013-04-14 17:36:27.754 UserDefinedTargets[1044:707] Invalid request to deactivate data set.

2013-04-14 17:37:26.856 UserDefinedTargets[1044:707] UDTParentViewController: creating

2013-04-14 17:37:26.858 UserDefinedTargets[1044:707] ARVC: loadView

2013-04-14 17:37:26.863 UserDefinedTargets[1044:707] QCAR OpenGL flag: 2

2013-04-14 17:37:26.864 UserDefinedTargets[1044:707] ARVC: viewDidLoad

2013-04-14 17:37:27.020 UserDefinedTargets[1044:707] QCARutils onCreate()

2013-04-14 17:37:27.021 UserDefinedTargets[1044:707] APPSTATUS_INIT_APP

2013-04-14 17:37:27.021 UserDefinedTargets[1044:707] APPSTATUS_INIT_QCAR

2013-04-14 17:37:27.029 UserDefinedTargets[1044:707] -[__NSCFDictionary orientationDidChange:]: unrecognized selector sent to instance 0x643ba0

2013-04-14 17:37:27.030 UserDefinedTargets[1044:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary orientationDidChange:]: unrecognized selector sent to instance 0x643ba0'

*** First throw call stack:

(0x37a3d8bf 0x315231e5 0x37a40acb 0x37a3f945 0x3799a680 0x3196250f 0x37a09577 0x379950cf 0x318d63fb 0x34dfac0f 0x34e38f01 0x6107 0x34e2e78b 0x34e3ac39 0x34e3aaa9 0x34e3a98f 0x34e3a211 0x34e39f53 0x34e2e673 0x34e2e349 0x1a581 0x37997435 0x34e109eb 0x34e109a7 0x34e10985 0x34e106f5 0x34e1102d 0x34e0399b 0x37a11b4b 0x37a0fd87 0x37a100e1 0x379934dd 0x379933a5 0x37511fcd 0x34e23743 0xa187 0x2390)

terminate called throwing an exception2013-04-14 17:37:27.030 UserDefinedTargets[1044:880f] INFO/AR(1044) 2013-04-14 17:37:27: QCAR SDK version 2.0.31

(lldb)

 

This is all the info that I can get in my tests.

 

Thank you very much!

jomavifi

 

UserDefinedTargets inside UINavigationController

April 12, 2013 - 9:07am #4

Hi jomavifi,

The reasons the screen is black is because it thinks the AR screen size is zero - check the log.

I was able to use the same technique as previously describe to get UDT running in a navigation controller with the following steps:

1 Create a new AppDelegate with a simplified launch, because it uses the Storyboard to find the initial VC

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    // Nalin

    

    // Create the UDT-specific QCARutils object to replace the standard one

    (void)[UDTQCARutils getInstance];

    

    

    // Override point for customization after application launch - allows my collection view controller rather than the default    

    return YES;

}

 

2  Create a new StartViewController that is tied to the root view controller off the Navigation Controller in the storyboard - in my case it has a single Go button that launches the AR.

 

@class UDTParentViewController;

 

@interface StartViewController : UIViewController

- (IBAction)goButton:(id)sender;

 

@property (strong, nonatomic) UDTParentViewController *cameraViewController;

 

@end

 
 

#import "StartViewController.h"

#import "UDTParentViewController.h"

 

@interface StartViewController ()

 

@end

 

@implementation StartViewController

 

@synthesize cameraViewController = _cameraViewController;

 

 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}

 

- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view.

    

    _cameraViewController = [[UDTParentViewController alloc] initWithNibName:nil bundle:nil];

    

    // need to set this so subsequent view controllers know the size 

    _cameraViewController.arViewSize = self.view.bounds.size;

}

 

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

- (void)dealloc

{

    [_cameraViewController release];

    [super dealloc];

}

 

 

- (IBAction)goButton:(id)sender {

 

    // need to set this so subsequent view controllers know the size

    [self.navigationController pushViewController:_cameraViewController animated:YES];

}

 

@end

 

3  Modify in the loadView() function where it sets the size of the AR to be the size that you pass in above:

 

    // need to set size here to setup camera image size for AR

    arViewController.arViewSize = arViewSize;

 

...and then it should work.

 

N

 

 

 

 

UserDefinedTargets inside UINavigationController

April 9, 2013 - 2:50pm #3

 

Hi NalinS,

First, thank you for your attention!

I've only tried integrating UserDedefinedTargets because I'm only working with this sample.

However, I have tried many ways to integrate this sample with different results. At first, I did everything by my own.  When I got app crashes, I searched for information on this forum to see if anyone had done this before

In the previous post, I showed the code where I use a button to push to UDT sample (I use just Storyboard for my personal code):

[self.navigationController pushViewController:udtViewController animated:YES];

In this case, when I go back to the DetailViewController and I push the button again, the AR-view is black instead of the camera view.

Other case with the same code: when I go back to the DetailViewController, and I go back to other ViewController (InitialViewController) and I turn the phone (change the orientation) to landscape the app crashes. The log is as follows:

The Output:

AR(15675) 2013-04-09 23:40:20: Successfully created ImageTarget.

2013-04-09 23:40:23.151 UserDefinedTargets[15675:707] ARParentVC: dissappeared

2013-04-09 23:40:23.152 UserDefinedTargets[15675:707] ARVC: viewDidDisappear

2013-04-09 23:40:23.153 UserDefinedTargets[15675:707] QCARutils onPause()

2013-04-09 23:40:23.154 UserDefinedTargets[15675:707] APPSTATUS_CAMERA_STOPPED

2013-04-09 23:40:24.019 UserDefinedTargets[15675:707] QCARutils onDestroy()

2013-04-09 23:40:24.020 UserDefinedTargets[15675:707] Invalid request to deactivate data set.

(lldb)

Debug Navigator:

libobjc.A.dylib`objc_msgSend:

0x3188efac:  teq.w  r0, #0

0x3188efb0:  beq    0x3188efee                ; objc_msgSend + 66

0x3188efb2:  push.w {r3, r4}

0x3188efb6:  ldr    r4, [r0]

0x3188efb8:  lsr.w  r9, r1, #2

0x3188efbc:  ldr    r3, [r4, #8]

...

The other way I've tried to integrate the example: I added a ViewController to my storyboard and changed it's class to the ARParentViewController.Now the button has no code, it has a segue to the new view (with class ARParentViewController).

To do this, I used the example of Danchoys and followed the indications of this post:

https://developer.vuforia.com/forum/ios/qcar-inside-uinavigationcontroller

In this case, I can see the camera and the navigation bar, but I can’t see the UDT sample controls. I can’t do anything in this view, just go back. (I think this might be because the ARParentViewController class has no specific tools of UserDefinedTargets sample, all is in UDTParentViewController..).

Thanks in advance!!

UserDefinedTargets inside UINavigationController

April 8, 2013 - 4:31am #2

 

but at some point the application crashes.

 
What does the xcode log say?
 
 
BTW Have you managed to integrate any of the other apps into a storyboard (as per the links) without it crashing e.g. cloud reco?
 
N

 

 

 

Log in or register to post comments