capacitor-community / privacy-screen

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.
MIT License
88 stars 23 forks source link

bug: Application tried to present modally a view controller <UIViewController: 0x10392e710> that is already being presented by <Capacitor.CAPBridgeViewController: 0x10390bf60>. #83

Closed qliqdev closed 7 months ago

qliqdev commented 1 year ago

Plugin version: 4.2.1

Platform(s): iOS

Current behavior:

App crashes

Expected behavior:

Steps to reproduce:

Seeing this crash log in crashlytics

Related code:

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                     0xed5e0 __exceptionPreprocess
1  libobjc.A.dylib                    0x2bc00 objc_exception_throw
2  UIKitCore                          0x7795f8 -[UIViewController _presentViewController:withAnimationController:completion:]
3  UIKitCore                          0x779d64 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2
4  UIKitCore                          0x42218 +[UIView(Animation) performWithoutAnimation:]
5  UIKitCore                          0x779ce4 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke
6  UIKitCore                          0x779f6c -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
7  UIKitCore                          0x779bd8 -[UIViewController _presentViewController:animated:completion:]
8  UIKitCore                          0x77a028 -[UIViewController presentViewController:animated:completion:]
9  CapacitorCommunityPrivacyScreen    0x4b08 closure #1 in PrivacyScreen.handleWillResignActiveNotification() + 44 (PrivacyScreen.swift:44)
10 CapacitorCommunityPrivacyScreen    0x41b4 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
11 libdispatch.dylib                  0x26a8 _dispatch_call_block_and_release
12 libdispatch.dylib                  0x4300 _dispatch_client_callout
13 libdispatch.dylib                  0x12998 _dispatch_main_queue_drain
14 libdispatch.dylib                  0x125b0 _dispatch_main_queue_callback_4CF
15 CoreFoundation                     0x379bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
16 CoreFoundation                     0x346c8 __CFRunLoopRun
17 CoreFoundation                     0x33e18 CFRunLoopRunSpecific
18 GraphicsServices                   0x35ec GSEventRunModal
19 UIKitCore                          0x22f2fc -[UIApplication _run]
20 UIKitCore                          0x22e938 UIApplicationMain
21 Bakai24                            0x93f8 main + 7 (AppDelegate.swift:7)
22 ???                                0x1b4277d44 (Missing)

Other information:

Device Model:iPhone 14 Pro Operating System Version:17.0.3

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1

Installed Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1

[success] iOS looking great! 👌
[success] Android looking great! 👌
qliqdev commented 1 year ago

can it be fixed with code below?

@objc public func handleWillResignActiveNotification() {
    guard self.isEnabled, !self.privacyViewController.isBeingPresented else {
        return
    }
    DispatchQueue.main.async {
        self.plugin.bridge?.viewController?.present(self.privacyViewController, animated: false, completion: nil)
    }
}
robingenz commented 8 months ago

Does the problem still exist with the latest version?

github-actions[bot] commented 7 months ago

It looks like there hasn't been a reply in 30 days, so I'm closing this issue.