swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

`WKWebView.takeSnapshot` failing to generate an image on Xcode 14 RC

Open marcosgriselli opened this issue 2 years ago • 3 comments

Describe the bug All WKWebView tests that require generating an image are crashing while force unwrapping an optional image on the takSnapshot completion handler.

To Reproduce Run the iOS tests on the swift-snapshot-testing repo's main branch with Xcode 14 RC.

Expected behavior Tests to pass

Screenshots

image

Environment

  • swift-snapshot-testing version: latest main
  • Xcode 14 RC
  • Swift 5.7
  • OS: 12.5.1

More information

Console output logs "Invalid connection identifier" which makes me wonder if Xcode is expecting network capabilities to launch this.

Test Case '-[SnapshotTestingTests.SnapshotTestingTests testWebView]' started.
2022-09-02 16:45:53.832110-0700 xctest[26474:1131098] [ProcessSuspension] endowmentsForHandle: Process with PID 26474 is not running
2022-09-02 16:45:53.874338-0700 xctest[26474:1131098] [Process] 0x160064100 - [PID=0] WebProcessProxy::didFinishLaunching: Invalid connection identifier (web process failed to launch)
2022-09-02 16:45:53.874399-0700 xctest[26474:1131098] [Process] 0x160064100 - [PID=0] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash
2022-09-02 16:45:53.874518-0700 xctest[26474:1131098] [Process] 0x13300ce18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::processDidTerminate: (pid 0), reason=Crash

marcosgriselli avatar Sep 02 '22 22:09 marcosgriselli

Still happening with Xcode 14 RC.

barrault01 avatar Sep 12 '22 09:09 barrault01

Still happening with Xcode 14.0.1. But only on iOS 16, iOS 15 is working fine.

A crash inside WKWebView occurs that seems to make the wkWebView.takeSnapshot(...) method to return an error instead of an image.

xctest[42043:34329227] [Process] 0x110064100 - [PID=0] WebProcessProxy::didFinishLaunching: Invalid connection identifier (web process failed to launch)
xctest[42043:34329227] [Process] 0x110064100 - [PID=0] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash
xctest[42043:34329227] [Process] 0x13a82da18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::processDidTerminate: (pid 0), reason=Crash
xctest[42043:34329227] [Loading] 0x13a82da18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: reason=Crash
xctest[42043:34329227] [Loading] 0x13a82da18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: Not eagerly reloading the view because it is not currently visible

I don't think this is caused by SnapshotTesting. Just using the takeSnapshot method without SnapshotTesting also fails. Weird that I can't find any other blog posts or issues about this.

Seems related to these: https://developer.apple.com/forums/thread/716354 https://developer.apple.com/forums/thread/712899 https://developer.apple.com/forums/thread/712349 https://developer.apple.com/forums/thread/713581 https://stackoverflow.com/questions/67067390

However, most of those are related to injecting javascript

teameh avatar Dec 20 '22 16:12 teameh

@barrault01 I've opened a PR with your commit because it does improve things a little bit.

teameh avatar Jan 03 '23 12:01 teameh