                     let aspectRatio = image.size.width / image.size.height
                     self.activityIndicator.isHidden = true
                     self.updateAspectRatio(forView: self.mainImageView, aspectRatio: aspectRatio)
-                    self.didLoad?()
+                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.01, execute: {
+                        self.didLoad?()
+                    })
                 }
                 self.mainImageView?.image = image
             }

        bringSubviewToFront(activityIndicator)
        activityIndicator.isHidden = false
        activityIndicator.startAnimating()

        guard let url = url else {
            stopPlayback()

        aspectRatioConstraint = constraint
    }

    @objc private func stopPlayback(andResetUrl reset: Bool = true) {
        if reset {
            url = nil
        }
        playerObserver = nil
        playerView?.playerLayer.player = nil
        mjpegRequest?.cancel()
        mjpegRequest = nil
        self.mainImageView?.image = nil
    }
}

