Start a new topic

IOS app crashes when starting AR

IOS app crashes when starting AR


Hi,

Does this info help:

Please note that the Wikitude iOS SDKs are now more strict when it comes to memory handling. In case an application creates multiple instances of the SDK, the hosting application needs to make sure that the previously created instance is destroyed properly before the new one is created. Otherwise the application will crash with an stack trace like this mentioning InitGoogleLogging() twice:
 

Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
*** Check failure stack trace: ***
   @        0x1002444b8  google::LogMessage::Flush()
   @        0x1002452d8  google::LogMessageFatal::~LogMessageFatal()
   @        0x100244804  google::LogMessageFatal::~LogMessageFatal()
   @        0x100248954  google::glog_internal_namespace_::InitGoogleLoggingUtilities()
   @        0x100377714  wikitude::common_library::impl::iOSConsoleWriter::iOSConsoleWriter()
   @        0x10019eca8  -
   @        0x10019c0b4  -
   @        0x10019bfac  -
   @        0x100149a38  -
   @        0x188993610  <redacted>
   @        0x1889ab6ec  <redacted>
   @        0x188b3fd68  <redacted>
   @        0x188a4f430  <redacted>
   @        0x188a4f10c  <redacted>
   @        0x188a4f074  <redacted>
   @        0x18898eff0  <redacted>
   @        0x188195f14  <redacted>
   @        0x188190b20  <redacted>
   @        0x1881909e0  <redacted>
   @        0x18819007c  <redacted>
   @        0x18818fdd0  <redacted>
   @        0x1881894bc  <redacted>
   @        0x1833f3c30  <redacted>
   @        0x1833f19d4  <redacted>
   @        0x1833f1e04  <redacted>
   @        0x183320dc0  CFRunLoopRunSpecific
   @        0x18e474088  GSEventRunModal
   @        0x1889faf44  UIApplicationMain
   @        0x100142000  main
   @        0x19885e8b8  <redacted>
 

The reason oftentimes is a retain cycle because the WTArchitectView or WTWikitudeNativeSDK object is strongly referenced in a block. Simply create a weak pointer to your Wikitude SDK object and use this weak pointer inside the block.

Greetings

Nicola

As i wrote before, the Error ist gone by explicitly calling architectView.RemoveFromSuperview() but i have wasted much time with building around the error/bug with a weak reference (seen before in the hint from Andreas Schacherbauer in the technical note).

Hi Frank.

 

Your solution does not work for me.  When i get back and re-open the ViewController then get the error ... it's frustrating

Regards

Hi Pedro,

i checked my solution again and noticed that there is another important step to do.

Here is my working code from the ViewController:

public override void ViewWillDisappear (bool animated) {
            

    base.ViewWillDisappear (animated);

    if (_architectView != null) {
        _architectView.Stop ();
        _architectView.RemoveFromSuperview ();
    }
    this.Dispose (true);

}

protected override void Dispose(bool disposing) {

     base.Dispose(disposing);


     if (_architectView != null) {
          _architectView.Dispose();
          _architectView = null;
     }


So not only the RemoveFromSuperview is important, also the overridden Dispose method is important too.

I hope it will work for you.

The problem is the C# Garbage Collector and the fact that the Wikitude SDK expects to be managed correctly and reliable since it is implemented in C++. That's why the xamarin application needs to make sure the memory is manged correctly and unfortunately you have to write some more code to get the garbage collector to do it's job as we expect in C++.

Best regards

Andreas

I've implemented the Wikitude SDK in my app in order to display my Wikitude Studio content inside my app. Everything works fine except for a thing, if I start the AR class then I go back to the home screen and finally I restart the AR the app crashes.
The crash occurs when calling:     self.architectView = ;

Does anyone know why does it happen and how to fix it?

Thanks

 

Hi Lorenzo,

Can you please over further details on the crash (crash log, stack trace) so we know the reason for the crash.

Thx and greetings

Nicola

This is the error log:

F1020 14:23:49.317847 2670616576 utilities.cc:320> Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!

*** Check failure stack trace: ***

    @        0x1002444b8  google::LogMessage::Flush()

    @        0x1002452d8  google::LogMessageFatal::~LogMessageFatal()

    @        0x100244804  google::LogMessageFatal::~LogMessageFatal()

    @        0x100248954  google::glog_internal_namespace_::InitGoogleLoggingUtilities()

    @        0x100377714  wikitude::common_library::impl::iOSConsoleWriter::iOSConsoleWriter()

    @        0x10019eca8  -

    @        0x10019c0b4  -

    @        0x10019bfac  -

    @        0x100149a38  -

    @        0x188993610  <redacted>

    @        0x1889ab6ec  <redacted>

    @        0x188b3fd68  <redacted>

    @        0x188a4f430  <redacted>

    @        0x188a4f10c  <redacted>

    @        0x188a4f074  <redacted>

    @        0x18898eff0  <redacted>

    @        0x188195f14  <redacted>

    @        0x188190b20  <redacted>

    @        0x1881909e0  <redacted>

    @        0x18819007c  <redacted>

    @        0x18818fdd0  <redacted>

    @        0x1881894bc  <redacted>

    @        0x1833f3c30  <redacted>

    @        0x1833f19d4  <redacted>

    @        0x1833f1e04  <redacted>

    @        0x183320dc0  CFRunLoopRunSpecific

    @        0x18e474088  GSEventRunModal

    @        0x1889faf44  UIApplicationMain

    @        0x100142000  main

    @        0x19885e8b8  <redacted>

Ok I got it working, the dealloc wasn't being called because I was referring to 'self' inside a block with a strong reference. What I did was create a weak self with __unsafe_unretained AugmentedRealityViewController *weakSelf = self;

and then inside the various blocks I used weakSelf instead of self, like this:
 

;

    ;

 

Now it works fine

You should update the docs because I took the code from there and with the sdk 5.0 I got this error that is the same error these guys are facing

It works !!!!!!!

Thank you very much Frank, you saved my life ... i have spent a long time with this issue. Just in time for upload the App with Wikitude 5.

Thanks !!

 

For me it worked once.

On the second enter/exit it crashes with the same error for me.


Then there must still be present an instance that has not been taken into account. Look at the example of Wikitude, and check if the instantiation is unique and Dispose() is actually called.

I think that the implementation of Wikitude is not quite comprehensively. I think that an existing instance should be eliminated or used when creating an Architect View.

Hi Lorenzo,

I Have the same problem using the Xamarin plugin. Do you have any solution for this?

 

Regards

I'm sorry but I never used Xamarin and I have no idea how the code works.. sorry

Hi Pedro,
Lorenzo gave the correct answer to the problem. When using the +addObserverForName method from the NSNotificationCenter, you need to make sure to not retain self inside the block. The solution is to create a weak representation of self which you can make with __unsafe_unretained or __weak. This breaks the dependency cycle and the Wikitude SDK can get deallocated.
 

Best regards

Andreas
Login or Signup to post a comment