Comments (5)
Dang, that's super frustrating π
A repro would be great. We haven't encountered this yet, but if we can narrow it down to a bug we can fix or file with Apple, that'd be great π
from swift-snapshot-testing.
Ok, I have finally managed to narrow down the cause to a single test function and have created a sample project which will repro the issue every time: https://github.com/mluisbrown/SnapshotBug
The README for the repo explains everything, but I'll copy some of it here so the information is all in one place:
When you run the tests (βU) they run fine but end in a crash in UIApplicationMain
:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
I have enabled Zombie Objects diagnostics for the test target and with that enabled you also get an error in the console similar to:
*** -[CALayer setNeedsLayout]: message sent to deallocated instance 0x60000327d100
You can make the bug happen earlier (before the tests end) if you uncomment the autoreleasepool
block in SnapshotBugTests.swift
This will cause a slightly different Zombie error to appear in the console:
*** -[UIWindowLayer isHidden]: message sent to deallocated instance 0x600000d4cd60
This bug is somehow related with the async nature of the test and the fact that SnapshotTesting
also uses XCWaiter
. This kind of test works fine when using ios-snapshot-test-case which is not async.
Somehow the combination of the two async code paths is probably causing the run loop to release objects which otherwise would not be released.
The root cause of the crashes is async tests similar to the once in the sample repo. Other types of async tests, eg with Nimble's toEventually
don't cause the problem, but they can surface the crash earlier in the test suite.
from swift-snapshot-testing.
Just to clarify, if you do your async testing using .asyncPullback
this issue does not exist. It's an issue if you use SnapshotTesting
together with your own async code.
So, I wouldn't categorize it as a bug necessarily, but it's something users should be aware of.
from swift-snapshot-testing.
I'm experiencing the same issue very frequently now and was able to catch it using the address sanitizer SUMMARY: AddressSanitizer: heap-use-after-free (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x1a547) in wrap_memcpy
.
Please let me know if there's more information that I can provide to help to isolate and fix this issue.
I also noticed it happens in a view controller snapshot test in which the view controller displays a MKMapView
, does not happen in any other of our snapshot tests.
from swift-snapshot-testing.
I'm going to convert this to a discussion, as @mluisbrown notes, it's something folks may want to be aware of. If there are future related issues found that are due to bugs in SnapshotTesting that we can fix, though, please do open an issue!
from swift-snapshot-testing.
Related Issues (20)
- Snapshots tests fail when Json returns in different order, HOT 1
- macCatalyst: Snapshots generated differ a lot between local computer and a MacStadium M1 mac mini HOT 1
- Run success on local and xcode on CI Runner but test failed when using fastlane run_tests HOT 5
- Text-based snapshots break across platforms due to line ending differences HOT 2
- Undefined symbols Linker command failed with exit code 1. HOT 1
- Snapshot adds imported module's name that fails match with reference shapshot
- Deadlock in inline snapshot testing HOT 4
- What's the way to use `assertSnapshot` in async test? HOT 3
- How to snapshot on special iOS version? HOT 1
- Optimizing Image Handling in Swift Snapshot Testing
- Snapshot of table view with combine receiver happens too late HOT 1
- swift-syntax 510.0.0 update not possible HOT 1
- How to generate iPhone 15 Snapshots with Xcode 15, as view.swift doesn't contain those dimensions HOT 1
- I get "Process completed with exit code 65" when I use "assertSnapshot(of: vc, as: .image)" function on GitHub Actions.
- `diffTool` have a Swift 6 warning on Xcode 15.3 with Strict Concurrency Checking set to Complete HOT 3
- Privacy manifest for AppStore releases HOT 1
- "The file β...β couldnβt be opened because you donβt have permission to view it" after switching branch
- Privacy manifest file / Privacy Rules HOT 1
- Blank diff snapshot
- Use keyboardLayoutGuide HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-snapshot-testing.