Hi Andreas,
in the Wikitude example the '-stop' method is called in the viewDidDisappear method:
- (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [self.wikitudeSDK stop]; [self.renderer stopRenderLoop]; [self.renderer teardownRendering]; [[NSNotificationCenter defaultCenter] removeObserver:self]; }
I tried viewWillDisappear instead of viewDidDisappear but it doesn't help.
Hi Andreas,
here is my customized Wikitude example code:
https://cap3gmbh.s3.amazonaws.com/public/Examples-01.zip
Perhaps it will not crash the first time coming back from the dummy view controller but on my test device (iPhone 6, iOS 10.1.1) the example always crashes.
I hope you can reproduce the problem.
Hi Ole,
can you make sure that the `-stop` method of our SDK is called when the new view controller is presented?!
Best regards,
Andreas
Hi Ole,
Did you check on which thread didRecognizedTarget is called? If its not the main thread, you should put your view controller code in a dispatch_async(dispatch_get_main_queue,... block.
Best regards,
Andreas
Hi Ole,
Thx for the demo project. I already had a look at it and could reproduce the issue. Unfortunately the fix causes another tricky issue which I'm now investigating. I send you more infos ASAP.
Best regards,
Andreas
Hi Andreas,
yes, I checked that, but I extended the minimal example to be sure:
- (void)baseTracker:(nonnull WTBaseTracker *)baseTracker didRecognizedTarget:(nonnull WTImageTarget *)recognizedTarget { NSLog(@"recognized target '%@'", [recognizedTarget name]); _isTracking = YES; NSLog(@"is main thread: '%@'", [NSThread isMainThread] ? @"yes" : @"no"); dispatch_async(dispatch_get_main_queue(), ^(void){ sleep(3); [self presentViewController:[UIViewController new] animated:YES completion:^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ sleep(3); dispatch_async(dispatch_get_main_queue(), ^(void){ [self dismissViewControllerAnimated:YES completion:nil]; }); }); }]; }); }
The problem stays the same. Some time after the error message ("unable to set renderbuffer storage from drawable") is logged the debugger hangs on this call:
#0 0x000000010085bf14 in wikitude::sdk_foundation::impl::CameraService::newPlatformCameraFrameAvailable(wikitude::sdk_foundation::impl::FrameInfo) ()
Do you have any other idea?
Thank you for your help!
Hi Ole,
Thx for the demo project. I'm able to reproduce the problem and started investigation. I let you know once I know more about the problem.
Best regards,
Andreas
Hi Ole,
I found the reason for the OpenGL error you experience. Luckily it's purely related to the example setup. You just need to do two small edits and it will work.
The first change is in the view controllers -viewDidDisappear: method. Simply replace it with the following snippet:
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.wikitudeSDK stop];
[self.renderableRectangle releaseProgram]; // first change
[self.renderer stopRenderLoop];
[self.renderer teardownRendering];
_sharedWikitudeEAGLCameraContext = nil; // second change
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
The second change is in the ExternalRenderer method -teardownRendering:
- (void)teardownRendering
{
self.externalRenderBlock = nil;
if (_colorRenderbuffer)
{
WT_GL_ASSERT( glDeleteRenderbuffers(1, &_colorRenderbuffer) );
}
if (_framebuffer)
{
WT_GL_ASSERT( glDeleteFramebuffers(1, &_framebuffer) );
}
if (_eaglContext)
{
[_eaglContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil]; // detach render buffer from the current context
self.eaglContext = nil;
}
}
I also only create the tracker if needed like this:
if ( !_clientTracker )
{
NSURL *clientTrackerURL = [[NSBundle mainBundle] URLForResource:@"magazine"withExtension:@"wtc" subdirectory:@"Assets"];
self.clientTracker = [self.wikitudeSDK.trackerManagercreate2DClientTrackerFromURL:clientTrackerURL extendedTargets:nil andDelegate:self];
}
Please let me know if that works for you.
Best regards,
Andreas
Hi Andreas,
thank you very much for your help. The crash does not occur anymore and we are really happy!
I have only one more question regarding your last hint: Sometimes our tracker file has to be updated while the app is running and the view is displayed. For Android there is a method called "destroyTracker" on the tracker manager. Is there any equivalent for iOS?
Thank you very much.
Hi Ole,
I'm glad it's working for you. We will update the example in the next release.
Regarding your tracker question: The equivalent on iOS is to set the tracker to nil.
Best regards,
Andreas
Hi Andreas,
alright, thanks again!
Hi Andreas,
thanks for the info, that's good to know!
Hi Ole,
You're welcome ;) Let me know if it's working.
Best regards,
Andreas
Ole Cordsen
If I adjust the iOS native example to present a view controller on successful target recognition like:
I get the following error message: "unable to set renderbuffer storage from drawable".
My example is kind of artificial but the same error occurs with a real view controller.
Do you have any hint for me? Thank you very much for any help.