Github user idpaterson commented on the pull request: https://github.com/apache/cordova-plugin-splashscreen/pull/56#issuecomment-132235333 Since the animation block must perform its changes synchronously in order to animate, adding `__block` as follows does not resolve the issue; the splash screen still does not fade. ```obj-c [UIView transitionWithView:self.viewController.view duration:fadeDuration options:UIViewAnimationOptionTransitionNone animations:^(void) { __block __typeof(self) strongSelf = weakSelf; if (strongSelf != nil) { dispatch_async(dispatch_get_main_queue(), ^{ [strongSelf->_activityView setAlpha:0]; [strongSelf->_imageView setAlpha:0]; }); } } completion:^(BOOL finished) { if (finished) { dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf destroyViews]; }); } } ]; ``` I believe that the most comprehensive solution to ensure that fading works and avoid threading issues is something like the following. I am not sure how or why `setVisible:` is being called on a background thread, but this would ensure that any resulting UI modifications are performed on the main thread. ```obj-c - (void)setVisible:(BOOL)visible { if (visible == _visible) { return; } _visible = visible; id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreen" lowercaseString]]; id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:[@"FadeSplashScreenDuration" lowercaseString]]; float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue]; if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue]) { fadeDuration = 0; } [self setVisible:visible fadeDuration:fadeDuration]; } - (void)setVisible:(BOOL)visible fadeDuration:(float)fadeDuration { if ([NSThread isMainThread]) { // Never animate the showing of the splash screen. if (visible) { if (_imageView == nil) { [self createViews]; } } else if (fadeDuration == 0) { [self destroyViews]; } else { __weak __typeof(self) weakSelf = self; [UIView transitionWithView:self.viewController.view duration:fadeDuration options:UIViewAnimationOptionTransitionNone animations:^(void) { __block __typeof(self) strongSelf = weakSelf; if (strongSelf != nil) { [strongSelf->_activityView setAlpha:0]; [strongSelf->_imageView setAlpha:0]; } } completion:^(BOOL finished) { if (finished) { [weakSelf destroyViews]; } } ]; } } else { dispatch_async(dispatch_get_main_queue(), ^{ [self setVisible:visible fadeDuration:fadeDuration]; }); } } ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org