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

Fix concurrency issue with Blaze local notification scheduler #14012

Merged
merged 4 commits into from
Sep 24, 2024

Conversation

itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Sep 23, 2024

Closes: #14011

Description

When enabling Core Data concurrency debugging, I got a crash in Blaze local notification scheduler's scheduleNoCampaignReminder method.

The reason is this method dispatches an async request to check for Blaze eligibility, and then start an observation of the storage for Blaze campaigns. This causes an issue when the observation is done on a background thread.

The fix is to ensure the method is called on the main thread. I moved all the @MainActor annotations to the protocol to also support Swift targeted concurrency check.

Steps to reproduce

Testing information

Tested on simulator iPad 10th gen iOS 17.4 and confirmed that the app no longer crashes in debug mode on dashboard screen.

Screenshots

N/A


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@itsmeichigo itsmeichigo added type: bug A confirmed bug. feature: Blaze Related to the integration of the Blaze ads platform labels Sep 23, 2024
@itsmeichigo itsmeichigo added this to the 20.6 milestone Sep 23, 2024
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@itsmeichigo itsmeichigo marked this pull request as ready for review September 23, 2024 06:10
@wpmobilebot
Copy link
Collaborator

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14012-7ec9cdd
Version20.5
Bundle IDcom.automattic.alpha.woocommerce
Commit7ec9cdd
App Center BuildWooCommerce - Prototype Builds #10943
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Comment on lines +127 to +128
argument = "-com.apple.CoreData.ConcurrencyDebug 1"
isEnabled = "YES">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit: I think you left the ConcurrencyDebug check enabled here 🙌

Copy link
Contributor Author

@itsmeichigo itsmeichigo Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmusolino I intentionally enabled that as default for now. This would only affect debug build runs. Could you share why we should avoid this?

@selanthiraiyan selanthiraiyan self-assigned this Sep 24, 2024
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, Huong! Thanks for fixing this.

I tested that Blaze local notifications are scheduled as before. ✅

@itsmeichigo itsmeichigo merged commit b155ebc into trunk Sep 24, 2024
14 checks passed
@itsmeichigo itsmeichigo deleted the fix/14011-concurrency-issue-blaze branch September 24, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: Blaze Related to the integration of the Blaze ads platform type: bug A confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Concurrency issue in BlazeLocalNotificationScheduler
5 participants