HCaptcha-ios-sdk icon indicating copy to clipboard operation
HCaptcha-ios-sdk copied to clipboard

iOS 14.x M1 simulators have a known issue with some standard features

Open fwx opened this issue 2 years ago • 9 comments

Bug description

Captcha is not displaying puzzle using iOS 14.5 Simulator

To Reproduce

Steps to reproduce the behavior:

  1. Initialize hCaptcha somewhere
  2. Try to call hCaptcha.validate using iOS 14.5 Simulator
  3. That step depends on config. If using invisible then nothing happens at all, but if compact is being used, then checkmark displays, but after pressing 'I am a human' nothing happens except one flicker.

Sample code:

captchaWebView?.removeFromSuperview()
        hCaptcha.configureWebView { [weak self] webview in
            self?.captchaWebView = webview
            webview.frame = view.bounds
        }
        
        hCaptcha.validate(on: view) { [weak self] result in
            guard let self = self else {
                return
            }
            print(try! result.dematerialize())
            self.captchaWebView?.removeFromSuperview()
        }

Expected behavior

hCaptcha displays puzzle

Logs

[JS LOG]: challenge executing
[JS LOG]: showing challenge
2022-12-08 23:55:41.012306+1000 APP_NAME[92271:1276150] [ProcessSuspension] 0x12b1b1c80 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID is invalid
2022-12-08 23:55:41.012478+1000 APP_NAME[92271:1276150] [Process] 0x152859018 - [pageProxyID=5, webPageID=6, PID=92278] WebPageProxy::processDidTerminate: (pid 92278), reason 3
2022-12-08 23:55:41.026291+1000 APP_NAME[92271:1276150] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2022-12-08 23:55:41.026374+1000 APP_NAME[92271:1276150] [ProcessSuspension] 0x12b1b1cc0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 92278, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2022-12-08 23:55:41.029488+1000 APP_NAME[92271:1276150] [Loading] 0x152859018 - [pageProxyID=5, webPageID=6, PID=92278] WebPageProxy::dispatchProcessDidTerminate: reason = 3

Additional context

Seems like thats an iOS bug related to WKWebView. I've tried enabling background capabilities but it didnt help. We have our own implementation of Google's ReCaptcha but I dont see any big difference in codes related to webview handling, so I am not kind of sure thats WKWebView problem

image

fwx avatar Dec 08 '22 14:12 fwx

Thanks for reporting the issue

I can confirm that permanent we content process termination happens only for 14.5. I have tested 15.5 and 16.2 but no such behavior was observed

This issue really looks like a bug in WebKit (because happens only for specific iOS version)

I will continue the investigation on our side, also SDK shouldn't fail "silent" and provide an error in completion closure (if web content process was killed)

BTW @fwx maybe you have a device with iOS 14.5 to confirm that this behavior happens for the actual device too?

P.S. Issue reproduces only for arm iOS 14.5 (x86_64 14.5 works fine)

CAMOBAP avatar Dec 25 '22 18:12 CAMOBAP

Sorry, but I dont have a device running iOS 14.5 : (

fwx avatar Dec 28 '22 04:12 fwx

Clearly looks like WebKit issue, because it reproduces on arm Simulator, but works fine for x86_64 Simulator

CAMOBAP avatar Jan 26 '23 13:01 CAMOBAP

Now SDK correctly handle WebContent process crash/termination

CAMOBAP avatar Jan 29 '23 20:01 CAMOBAP

Closing for now.

e271828- avatar Jan 29 '23 20:01 e271828-

Troubleshooting continued

CAMOBAP avatar Mar 09 '23 20:03 CAMOBAP

According to our investigation:

Our mobile team finished an investigation about iOS 14 Simulator and it seems it’s a pretty well-known simulator issue related to WebGL, that was not fixed.

  • https://github.com/mapbox/mapbox-gl-js/issues/10260 - iOS Simulator Safari crashes running on M1 Chip mac
  • https://developer.apple.com/forums/thread/662251 - Site using WebGL rendering crashes in Safari browser with iOS 14.2 Beta (but works in the stable iOS 14)

As a diagnostic step, you can try to use test sitekeys with hardcoded results: https://docs.hcaptcha.com/#integration-testing-test-keys, which should omit problems with the simulator. Also, we can suggest testing if functionalities are working on real devices

So per our investigation it's simulator only problem and it's not affect real devices

@fwx could you please try with test sitekeys from https://docs.hcaptcha.com/#integration-testing-test-keys ?

CAMOBAP avatar Mar 21 '23 14:03 CAMOBAP

@CAMOBAP

Sorry for such a long answer. So it is working

[JS LOG]: challenge executing
[JS LOG]: showing challenge
[JS LOG]: challenge got token
[JS LOG]: 10000000-aaaa-bbbb-cccc-000000000001

The captcha was not presented and I just got the token immediately. iOS 14.5 via iPhone 12 simulator running on Apple's M1 chip, Xcode version is 14.2.

Then I tried one more time and this error happened:

[JS LOG]: challenge executing
[JS LOG]: showing challenge
[JS LOG]: challenge opened
2023-03-29 20:10:27.428918+0700 App-Stage[54360:19363511] [ProcessSuspension] 0x137ab2640 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID is invalid
2023-03-29 20:10:27.429092+0700 App-Stage[54360:19363511] [Process] 0x13aa86018 - [pageProxyID=5, webPageID=6, PID=54365] WebPageProxy::processDidTerminate: (pid 54365), reason 3
2023-03-29 20:10:27.444629+0700 App-Stage[54360:19363511] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2023-03-29 20:10:27.444706+0700 App-Stage[54360:19363511] [ProcessSuspension] 0x137ab2680 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 54365, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2023-03-29 20:10:27.448214+0700 App-Stage[54360:19363511] [Loading] 0x13aa86018 - [pageProxyID=5, webPageID=6, PID=54365] WebPageProxy::dispatchProcessDidTerminate: reason = 3

Yea I guess we're just looking at Apple's bug and it is probably working on a device running 14.5

fwx avatar Mar 29 '23 13:03 fwx

Let's just add a note to docs, this seems like a known simulator bug that does not affect real devices.

e271828- avatar May 30 '23 14:05 e271828-