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

[YiR] Only populate after login if app has resumed #5083

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

tonisevener
Copy link
Collaborator

@tonisevener tonisevener commented Nov 19, 2024

Phabricator: https://phabricator.wikimedia.org/T378135

Notes

This fixes a console complaint I started to notice today:

Failure populating year in review report: Error Domain=NSCocoaErrorDomain Code=133020 "Could not merge changes." UserInfo={conflictList=(
    "NSMergeConflict (0x6000017d5140) for NSManagedObject (0x60000212cb40) with objectID '0x9c481419d6f2b090 <x-coredata://020B8A47-5DE5-4220-A266-679DB4FEA54B/CDYearInReviewSlide/p1>' with oldVersion = 1 and newVersion = 2 and old object snapshot = {\n    data = \"<null>\";\n    display = 0;\n    evaluated = 0;\n    id = readCount;\n    report = \"0x9c481419d6f2b0a0 <x-coredata://020B8A47-5DE5-4220-A266-679DB4FEA54B/CDYearInReviewReport/p1>\";\n    year = 2024;\n} and new cached row = {\n    data = {length = 1, bytes = 0x30};\n    display = 0;\n    evaluated = 1;\n    id = readCount;\n    report = \"0x9c481419d6f2b0a0 <x-coredata://020B8A47-5DE5-4220-A266-679DB4FEA54B/CDYearInReviewReport/p1>\";\n    year = 2024;\n}"
), NSExceptionOmitCallstacks=true} [WMFAppViewController+Extensions#L626]

I think this is caused by my additional call to populate YiR report data after the user logs in (added in #5074). When an app launches, it makes the populateYearInReviewReport method call twice fairly quickly: Once from performTasksThatShouldOccurAfterBecomeActiveAndResume after the app finishes its launch setup code, and again from userWasLoggedIn. I think something about this is causing merge conflicts on Core Data (the initial report without editing data attempts to save at the same time as the next report with editing data).

To get around this, I am only calling populateYearInReviewReport within userWasLoggedIn if the app has already completed its setup.

Test Steps

  1. Ensure you are logged into app for a user with edits from the past year. Delete app, then run again from this branch.
  2. Ensure Year in Review entry point appears. Ensure console error does not display.

@tonisevener tonisevener requested review from a team and mazevedofs and removed request for a team November 19, 2024 00:05
@tonisevener tonisevener changed the base branch from main to release/7.6.2 November 19, 2024 14:46
@tonisevener tonisevener changed the base branch from release/7.6.2 to main November 19, 2024 14:47
@l-olson1214 l-olson1214 self-requested a review November 25, 2024 19:47
@l-olson1214 l-olson1214 merged commit 15dd5a9 into main Nov 25, 2024
4 checks passed
@l-olson1214 l-olson1214 deleted the fix-console-merge-complaint branch November 25, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants