Skip to content

DebugViewModel: fixed runtime crash on iOS < 16#3139

Merged
NachoSoto merged 1 commit into
mainfrom
debug-model-runtime-crash
Sep 5, 2023
Merged

DebugViewModel: fixed runtime crash on iOS < 16#3139
NachoSoto merged 1 commit into
mainfrom
debug-model-runtime-crash

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Fixes RevenueCat/purchases-capacitor#100 and https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14093/workflows/b3f8d001-6f39-40db-a5c5-00fc37d0211e/jobs/105838

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                           	               0x0 ???
1   libswiftCore.dylib            	       0x18f9b8cf8 swift_getSingletonMetadata + 956
2   RevenueCat                    	       0x107f42de4 type metadata accessor for DebugViewModel + 64
3   libobjc.A.dylib               	       0x18017d938 realizeClassMaybeSwiftMaybeRelock(objc_class*, mutex_tt<false>&, bool) + 116
4   libobjc.A.dylib               	       0x180184eb0 realizeAllClasses() + 168
5   libobjc.A.dylib               	       0x180187b3c objc_copyClassList + 36
6   XCTestCore                    	       0x10532fcb0 +[XCTestCase(RuntimeUtilities) _allSubclasses] + 36
7   XCTestCore                    	       0x10532fdb8 +[XCTestCase(RuntimeUtilities) allSubclasses] + 16

Both XCTest (to load tests at runtime) and Capacitor use objc_getClassList. That's broken before iOS 16 and will try to load the metadata for DebugViewModel even though it's not @available.
A similar issue has been reported before: https://openradar.appspot.com/radar?id=4970535809187840 / swiftlang/swift#58099

This adds a layer of indirection so loading DebugViewModel at runtime doesn't require the metadata for NavigationPath.

Fixes RevenueCat/purchases-capacitor#100 and https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14093/workflows/b3f8d001-6f39-40db-a5c5-00fc37d0211e/jobs/105838

Both `XCTest` (to load tests at runtime) and `Capacitor` use `objc_getClassList`. That's broken before iOS 16 and will try to load the metadata for `DebugViewModel` even though it's not `@available`.
A similar issue has been reported before: https://openradar.appspot.com/radar?id=4970535809187840 / swiftlang/swift#58099

This adds a layer of indirection so loading `DebugViewModel` at runtime doesn't require the metadata for `NavigationPath`.
@NachoSoto NachoSoto added the pr:fix A bug fix label Sep 5, 2023
@NachoSoto NachoSoto requested a review from a team September 5, 2023 16:03
@NachoSoto NachoSoto enabled auto-merge (squash) September 5, 2023 16:45
@NachoSoto NachoSoto merged commit 0608e97 into main Sep 5, 2023
@NachoSoto NachoSoto deleted the debug-model-runtime-crash branch September 5, 2023 17:12
NachoSoto pushed a commit that referenced this pull request Sep 5, 2023
**This is an automatic release.**

### Bugfixes
* `DebugViewModel`: fixed runtime crash on iOS < 16 (#3139) via
NachoSoto (@NachoSoto)
### Performance Improvements
* `PurchasesOrchestrator`: return early if receipt has no transactions
when checking for promo offers (#3123) via Mark Villacampa
(@MarkVillacampa)
* `Purchases`: don't clear intro eligibility / purchased products cache
on first launch (#3067) via NachoSoto (@NachoSoto)
### Dependency Updates
* `SPM`: update `Package.resolved` (#3130) via NachoSoto (@NachoSoto)
### Other Changes
* `ReceiptParser`: fixed SPM build (#3144) via NachoSoto (@NachoSoto)
* `carthage_installation_tests`: optimize SPM package loading (#3129)
via NachoSoto (@NachoSoto)
* `CI`: add workaround for `Carthage` timing out (#3119) via NachoSoto
(@NachoSoto)
* `Integration Tests`: workaround to not lose debug logs (#3108) via
NachoSoto (@NachoSoto)
MarkVillacampa pushed a commit that referenced this pull request Sep 6, 2023
Fixes RevenueCat/purchases-capacitor#100 and
https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14093/workflows/b3f8d001-6f39-40db-a5c5-00fc37d0211e/jobs/105838

```
Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                           	               0x0 ???
1   libswiftCore.dylib            	       0x18f9b8cf8 swift_getSingletonMetadata + 956
2   RevenueCat                    	       0x107f42de4 type metadata accessor for DebugViewModel + 64
3   libobjc.A.dylib               	       0x18017d938 realizeClassMaybeSwiftMaybeRelock(objc_class*, mutex_tt<false>&, bool) + 116
4   libobjc.A.dylib               	       0x180184eb0 realizeAllClasses() + 168
5   libobjc.A.dylib               	       0x180187b3c objc_copyClassList + 36
6   XCTestCore                    	       0x10532fcb0 +[XCTestCase(RuntimeUtilities) _allSubclasses] + 36
7   XCTestCore                    	       0x10532fdb8 +[XCTestCase(RuntimeUtilities) allSubclasses] + 16
```

Both `XCTest` (to load tests at runtime) and `Capacitor` use
`objc_getClassList`. That's broken before iOS 16 and will try to load
the metadata for `DebugViewModel` even though it's not `@available`.
A similar issue has been reported before:
https://openradar.appspot.com/radar?id=4970535809187840 /
swiftlang/swift#58099

This adds a layer of indirection so loading `DebugViewModel` at runtime
doesn't require the metadata for `NavigationPath`.
MarkVillacampa pushed a commit that referenced this pull request Sep 6, 2023
**This is an automatic release.**

### Bugfixes
* `DebugViewModel`: fixed runtime crash on iOS < 16 (#3139) via
NachoSoto (@NachoSoto)
### Performance Improvements
* `PurchasesOrchestrator`: return early if receipt has no transactions
when checking for promo offers (#3123) via Mark Villacampa
(@MarkVillacampa)
* `Purchases`: don't clear intro eligibility / purchased products cache
on first launch (#3067) via NachoSoto (@NachoSoto)
### Dependency Updates
* `SPM`: update `Package.resolved` (#3130) via NachoSoto (@NachoSoto)
### Other Changes
* `ReceiptParser`: fixed SPM build (#3144) via NachoSoto (@NachoSoto)
* `carthage_installation_tests`: optimize SPM package loading (#3129)
via NachoSoto (@NachoSoto)
* `CI`: add workaround for `Carthage` timing out (#3119) via NachoSoto
(@NachoSoto)
* `Integration Tests`: workaround to not lose debug logs (#3108) via
NachoSoto (@NachoSoto)
tonidero added a commit that referenced this pull request Sep 14, 2023
### Description
We found that there was another runtime crash in Capacitor in iOS < 15
similar to #3139. This
applies the same fix to this new crash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS 15.5 Example purchase-tester App Stuck in Blank Screen

2 participants