Skip to content

AAAttribution.attributionToken: avoid using on main thread#3281

Merged
NachoSoto merged 3 commits into
mainfrom
attribution-token-async
Oct 6, 2023
Merged

AAAttribution.attributionToken: avoid using on main thread#3281
NachoSoto merged 3 commits into
mainfrom
attribution-token-async

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

Fixes #3280.

Turns out that AAAttribution.attributionToken() is asynchronous, and Apple will happily allow you to make a blocking network request on the main thread. This avoids that.

I've refactored AttributionFetcher.adServicesToken to be async and added RCTestAssertNotMainThread to ensure this doesn't break again.

The rest of the changes were necessary to accommodate the new async API.

@NachoSoto NachoSoto added the perf label Oct 5, 2023
@NachoSoto NachoSoto requested a review from a team October 5, 2023 19:04
@NachoSoto NachoSoto force-pushed the attribution-token-async branch from 479866f to 83cc0f9 Compare October 5, 2023 20:53
@NachoSoto NachoSoto marked this pull request as ready for review October 5, 2023 20:54
@aboedo

aboedo commented Oct 5, 2023

Copy link
Copy Markdown
Member

CI is angry, we might be missing some availability checks.

Thanks for taking care of this!

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Yeah thanks! I still don't know why I can't reproduce those errors locally (requiring iOS 13 for any concurrency API).

@NachoSoto NachoSoto force-pushed the attribution-token-async branch 2 times, most recently from 1001da4 to 8c99095 Compare October 5, 2023 21:30
@NachoSoto NachoSoto enabled auto-merge (squash) October 5, 2023 22:35
@NachoSoto NachoSoto force-pushed the attribution-token-async branch from 8c99095 to c15ac21 Compare October 5, 2023 22:35
@NachoSoto NachoSoto merged commit c3d00a4 into main Oct 6, 2023
@NachoSoto NachoSoto deleted the attribution-token-async branch October 6, 2023 04:20
NachoSoto pushed a commit that referenced this pull request Oct 6, 2023
**This is an automatic release.**

### RevenueCatUI
* `Paywalls`: improved purchase-in-progress UI (#3279) via NachoSoto
(@NachoSoto)
### Bugfixes
* `SK2StoreProduct.priceFormatter`: use locale from `StoreKit.Product`
(#3278) via NachoSoto (@NachoSoto)
### Performance Improvements
* `AAAttribution.attributionToken`: avoid using on main thread (#3281)
via NachoSoto (@NachoSoto)
### Other Changes
* `Paywalls Tester`: group live paywalls by template (#3276) via
NachoSoto (@NachoSoto)
@vegaro vegaro added pr:other and removed pr:perf labels Sep 17, 2024
@codecov

codecov Bot commented Sep 17, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 91.54930% with 12 lines in your changes missing coverage. Please review.

Project coverage is 85.85%. Comparing base (0bec5b9) to head (c15ac21).
Report is 539 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Attribution/AttributionFetcher.swift 70.96% 9 Missing ⚠️
Sources/Attribution/AttributionPoster.swift 87.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3281      +/-   ##
==========================================
+ Coverage   85.82%   85.85%   +0.03%     
==========================================
  Files         236      236              
  Lines       16790    16822      +32     
==========================================
+ Hits        14410    14443      +33     
+ Misses       2380     2379       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Purchases is blocking the main thread at app launch and at app return to foreground

3 participants