[iOS] App crash when change parameter image

Hi all,
I use the demo app from DeepAR (quickstart-ios-objc) to test some functionality of the DeepAr SDK.
I tried changing some texture images of the “MakeupLook.deepar” effect, but the app crashed after a few changes.

Sample code:

#pragma mark - DeepAr Delegate - 
- (void)didInitialize {
    [self.deepar switchEffectWithSlot:@"effect" path:[[NSBundle mainBundle]  pathForResource:@"MakeupLook.deepar" ofType:@""]];
    [self.cameraController startCamera];
}


#pragma mark - User change effect - 
- (void)changeTextures:(int)selectedIdx {
[self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    [self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    [self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
    
    [self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    [self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    [self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
    
    [self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    [self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    [self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
}

But app crashed when I change texture for 2 or 3 times

Another scenario: if no human face in front of camera => console log showed and App crashed:

2023-03-21 17:53:14.713021+0700 quickstart-ios-objc[15777:2076415] [Unknown process name] CGContextDrawImage: invalid context 0x0.

Can anyone help me?
Thanks!

Blockquote

Hi, the console log shouldn’t be an issue, as for the change parameter app. Could you help us check if the crash still happens if you only switch one texture per frame?

if i modify the code to change only 1 texture it still crashes, but at a lower rate.

#pragma mark - User change effect - 
- (void)changeTextures:(int)selectedIdx {
    [self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    //[self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    //[self.deepar changeParameter:@"FACE" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
    
    //[self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    //[self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    //[self.deepar changeParameter:@"lip_gloss" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
    
    //[self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texColor" image:[UIImage imageNamed:self.textures[selectedIdx].texColor]];
    //[self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texNormal" image:[UIImage imageNamed:self.textures[selectedIdx].texNormal]];
    //[self.deepar changeParameter:@"pPlane3" component:@"MeshRenderer" parameter:@"s_texMult" image:[UIImage imageNamed:self.textures[selectedIdx].texMult]];
}

App crashes after I press the button to change texture continuously about 8-9 times.

@jelena I uploaded a modified project based on DeepAR’s demo project. demo project
Can you help me check it?

P/S: The textures is random and may not be exact, but you can replace it with your own textures. (Sorry for the inconvenience)

Thanks!

Thank you for the example, we will have a look.

1 Like

Did you find any solution for this? @longvt

This bug has been fixed in the latest version of the DeepAR framework.
Thanks!

1 Like