From 46c6d1057d67f605eb1286785b277b09662e9934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 10 Feb 2023 16:19:33 +0100 Subject: [PATCH] fix(ios) avoid getting duplicated SDK events UIView has 2 designated initializers: initWithFrame and initWithCoder, which means either of them is going to be called, whatever the constructor. THus overriding init will cause creating new (and unnecessary) observers. Ref: https://community.jitsi.org/t/duplicate-delegate-calls/121051/6 Fixes: https://github.com/jitsi/jitsi-meet/issues/12892 --- ios/sdk/src/JitsiMeetView.m | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m index 53a09252b..8ca3c6c0a 100644 --- a/ios/sdk/src/JitsiMeetView.m +++ b/ios/sdk/src/JitsiMeetView.m @@ -40,19 +40,10 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled"; #pragma mark Initializers -- (instancetype)init { - self = [super init]; - if (self) { - [self initWithXXX]; - } - - return self; -} - - (instancetype)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { - [self initWithXXX]; + [self doInitialize]; } return self; @@ -61,7 +52,7 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled"; - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { - [self initWithXXX]; + [self doInitialize]; } return self; @@ -71,9 +62,9 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled"; * Internal initialization: * * - sets the background color - * - initializes the external API scope + * - registers necessary observers */ -- (void)initWithXXX { +- (void)doInitialize { // Set a background color which is in accord with the JavaScript and Android // parts of the application and causes less perceived visual flicker than // the default background color.