Start a new topic

Wikitudeview does not get deallocated

Wikitudeview does not get deallocated

Hi Dietmar,

You can also define a __weak ARViewController *weakSelf = self; outside of the notification block and use weakSelf inside the notification block. That should work as well.


Maybe this link helps as well.


Best regards,

Andreas


Ok I finally found a solution. I need to keep a close eye on those 2 observers and kill / restart them on viewDidDisappear and viewWillAppear. I **do not** register the observers during viewDidLoad.


My Header does look like this now:

ARViewController.h

    #import <UIKit/UIKit.h>

    #import <WikitudeSDK/WikitudeSDK.h>

    @interface ARViewController : UIViewController <WTArchitectViewDelegate>

    - (IBAction)leftButtonClick:(id)sender;

    @property (nonatomic, weak) IBOutlet WTArchitectView  *architectView;

    @property (nonatomic, weak) WTNavigation              *architectWorldNavigation;

    @property (nonatomic, weak) UIViewController <WTArchitectViewDelegate> *weakSelf;

    @property (nonatomic, weak) id observer1;

    @property (nonatomic, weak) id observer2;

    @end


ARViewController.m

    - (void)dealloc

    {

        ;

        ;

    }

    ...

    - (void)viewWillAppear:(BOOL)animated {

        ;

        // handle interruption

        _observer1 = ;

        _observer2 = ;

        ;

    }


    - (void)viewDidDisappear:(BOOL)animated {

        ;

        NSLog(@"viewDidDisappear...");

        ;

        ;

        ;

    }


Hey I have the same problem as others who posted on this forum:


Here is what I asked on Stackoverflow about it and what I found out so far:


(http://stackoverflow.com/questions/36998351/wikitude-sdk-detected-multiple-sdk-allocations)


Hey I have created an `objective-C` storyboard app in `Xcode`. I do have a `navigation` and I am able to switch to different views with that. The view I leave gets `deallocated` except the view I use for my Augmented Reality experience. The view is mostly copied from here:

https://github.com/Wikitude/wikitude-sdk-basic-projects/blob/master/iOS/AugmentedRealityApplication/ViewController.m


The Error I get is the following:

    > 2016-04-28 14:43:00.612 CPBVOCA ----------------- Wikitude SDK DETECTED MULTIPLE SDK ALLOCATIONS -----------------

    > 2016-04-28 14:43:00.613 CPBVOCA A second object of type WTArchitectView was created while the previous one was not deallocated.

    > 2016-04-28 14:43:00.613 CPBVOCA If this behaviour was not intended (multiple architect views at the same time), The WTArchitectView didn't got a call to dealloc.

    > 2016-04-28 14:43:00.613 CPBVOCA There might be a strong reference to a WTArchitectView objects captured in a block, e.g. in a NSNotificationCenter -addObserverForName:object:queue:usingBlock: method call.

    > 2016-04-28 14:43:00.614 CPBVOCA To disable this check (including the call to abort()), simply set the environment variable 'WTSDKDisableDeallocValidation' to YES.


I have already made a weak reference to self (as suggested here http://stackoverflow.com/questions/9219030/dealloc-not-being-called-on-arc-app) by creating the following in the header file :


ARViewController.h

@property (nonatomic, weak) UIViewController <WTArchitectViewDelegate> *weakSelf;


I did also replace the reference inside the `viewDidLoad` function:

ARViewController.m

    -(void)viewDidLoad{

         _weakSelf = self;

         ...

         //self.architectView.delegate = self;

         self.architectView.delegate = _weakSelf;

    }


But the problem still persists. What prevents the view from getting `deallocated`?


?:

I think I found the Problem:

there are 2 obeservers created for the notification center which references the ArchitectView

        ;

        ;


Where do I remove those 2 observers since `dealloc` does not get called if they are still registered?


In your github example those 2 observers are removed via the dealloc but this does not really work. If I don't use those 2 notifications the App will run just fine and it will dealloc the view.


The 2 Observers are needed to stop and start the scanner when the camera permission pops up.

Hope you can help me out on that one.

Login or Signup to post a comment