Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow graceful period to work around slow receipt validation #1139

Merged
merged 16 commits into from
Feb 5, 2025

Conversation

keeshux
Copy link
Member

@keeshux keeshux commented Feb 5, 2025

#1070 is very tricky. When the device boots, StoreKit operations seem to be severely affected by on-demand VPN profiles. Slowdowns are huge and unpredictable, as per my report on the Apple forums. I found no easy way to work around the chicken-and-egg situation where the VPN requires StoreKit validation to start, but StoreKit requires network access.

On the other hand, without StoreKit validations, the on-demand tunnel starts on boot just fine, and so does the app. No eternal activity indicators. StoreKit is clearly the culprit here.

Therefore, below is the strategy that this PR implements for a decent trade-off:

  • Configure a graceful period for the VPN to start without limitations. This is initially set to 2 minutes in production, and 10 minutes in TestFlight. Postpone StoreKit validation until then.
  • After the graceful period, StoreKit validation is more likely to complete fast
  • At this point, paying users have their receipts validated and the connection will silently keep going
  • Non-paying users, instead, will see their connection hit the "Purchase required" message

On the UI side, adjust the app accordingly:

  • Drop the "Purchase required" icon from the list/grid of profiles
  • The paywall informs that the connection will start, but it will disconnect after the graceful period if the receipt is not valid
  • Add a note that receipt validation may take a while if the device has just started

This PR also introduces changes in TestFlight behavior:

  • Profiles can be saved without limitations
  • Profiles using free features work as usual
  • Profiles using paid features work for 10 minutes
  • Eligibility based on local receipt is ignored (deprecated in iOS 18)

Beta users may therefore test all paid features on iOS/macOS/tvOS for 10 minutes. Until now, paid features were only available to paying iOS users and unavailable on macOS/tvOS. The tvOS beta was, in fact, completely useless.

The downside is that paying iOS users will see beta builds restricted like anybody else. I'll see if I can find a better solution later.

Verify connection after:

- 2 minutes (App Store)
- 10 minutes (TestFlight)
- Rename Fallback- to SharedReceiptReader
- Discontinue local receipt (Kvitto)
- Get rid of all beta receipt hacks
- Use timeout in fetchProducts()
- Parallelize AppTransaction and Transaction.currentEntitlements
Start the tunnel without restrictions, then verify purchases
after a delay (based on the user level). This mitigates the slow
StoreKit responses often experienced on device boot.

If verification fails, put the tunnel on hold (active but idle) to
avoid on-demand reconnections and allow the user to see the
"Purchase required" message in the app.
Prevent infinite on-demand reconnection.
Fix second paywall on interactive login by propagating the
verify flag.
Stop saving ineligible profiles. Also fix a bug where a profile
was being saved despite choosing "Cancel" in the paywall.
@keeshux keeshux self-assigned this Feb 5, 2025
@keeshux keeshux added the bug Something isn't working label Feb 5, 2025
@keeshux keeshux added this to the 3.1.0 / Hotfixes milestone Feb 5, 2025
@keeshux keeshux force-pushed the bugfix/slow-receipt-verification branch from 295d4e6 to 6c7e6e1 Compare February 5, 2025 11:14
@keeshux keeshux merged commit d6c2a7f into master Feb 5, 2025
1 check passed
@keeshux keeshux deleted the bugfix/slow-receipt-verification branch February 5, 2025 12:00
@keeshux keeshux mentioned this pull request Feb 5, 2025
keeshux added a commit that referenced this pull request Feb 5, 2025
- Add to "General" module on macOS
- Restore in profiles list/grid, removed in #1139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant