Start a new topic

unable to set renderbuffer storage from drawable

If I adjust the iOS native example to present a view controller on successful target recognition like: 

- (void)baseTracker:(nonnull WTBaseTracker *)baseTracker didRecognizedTarget:(nonnull WTImageTarget *)recognizedTarget
{
  NSLog(@"recognized target '%@'", [recognizedTarget name]);
  _isTracking = YES;
  
  [self presentViewController:[UIViewController new] animated:YES completion:^{
    sleep(3);
    [self dismissViewControllerAnimated:YES completion:nil];
  }];
}

  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.


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 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,

can you make sure that the `-stop` method of our SDK is called when the new view controller is presented?!


Best regards,

Andreas

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 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 defaultCenterremoveObserver:self];

}

 

The second change is in the ExternalRenderer method -teardownRendering:

- (void)teardownRendering

{

   self.externalRenderBlock = nil;


   if (_colorRenderbuffer)

    {

       WT_GL_ASSERTglDeleteRenderbuffers(1, &_colorRenderbuffer) );

    }


   if (_framebuffer)

    {

       WT_GL_ASSERTglDeleteFramebuffers(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 mainBundleURLForResource:@"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 Ole,

You're welcome ;) Let me know if it's working.


Best regards,

Andreas

Hi Andreas,


I made some tests and unfortunately setting the clientTracker to nil results in a crash for me when trying to create a new tracker. The app crashs too if I don't set the old one to nil. Do you have an idea what I might be doing wrong?


I only have this stack trace:


#0 0x000000010071bf14 in wikitude::sdk_foundation::impl::CameraService::newPlatformCameraFrameAvailable(wikitude::sdk_foundation::impl::FrameInfo) ()

#1 0x00000001005c4ed4 in _ZNSt3__110__function6__funcIZZ97-[WTNativeSDKManager cameraPlatformService:didOutputNextCameraFrameWithId:presentationTimestamp:]EUb_E3$_2NS_9allocatorIS2_EEFvRN8wikitude14sdk_foundation4impl13CameraServiceEEEclES9_ ()

#2 0x00000001005c401c in __97-[WTNativeSDKManager cameraPlatformService:didOutputNextCameraFrameWithId:presentationTimestamp:]_block_invoke ()

Hi Ole,

I tried it myself right now with our latest release (1.4.1) and was unable to reproduce the issue. Can you send us a code snippet where you delete the tracker and create a new one?


THX!

Andreas

Hi Andreas,

thanks for your reply. I'm not in the office today so I unfortunately can't build an example right now. What I tried was doing it like in the original example (without your suggested last fix which checks if _clientTracker is still nil before creating a new one). So everytimes when entering the view, when the SDK gets started I set _clientTracker to nil and call [self.wikitudeSDK.trackerManagercreate2DClientTrackerFromURL:clientTrackerURL extendedTargets:nil andDelegate:self];
After presenting a modal view controller and coming back like in our example a few times I got the crash.
I can send a full code example next week if needed.

Thanks,
Ole

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.

Login or Signup to post a comment