Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Dec 4, 2023

Fixes #22116

ReaderDetailToolbar can remain active in one tab while changes to the Post object can happen in another tab. To avoid issues, unsubscribe to Post changes when the view disappears.

I could not reproduce the crash but based on the logs the crash would happen during logout when accessing likesCount in ReaderDetailToolbar. It looks like Post observer is triggered during the logout process and the app crashes when we try to access no longer valid Post object. It happens because we remove Post observer in ReaderDetailToolbar.deinit() which isn't called when we switch from Reader tab to Me tab.

Solution

Connect Post observing to ReaderDetailViewController life cycle.

The other option I considered is moving all the observation logic to ReaderDetailViewController and then call specific methods of ReaderDetailToolbar to update the view. Do you think that would be preferable?

To test:

Open Reader Details, and then switch tabs, for example:

  1. Open Reader
  2. Search for a site
  3. Select site
  4. Select post
  5. Switch to another tab
  6. Confirm unsubscribePostChanges is called
  7. Come back to Reader tab
  8. Confirm subscribePostChanges is called

Regression Notes

  1. Potential unintended areas of impact

When Reader Detail view disappears, we stop observing likes and comments. If that wasn't intentional, then it could be an indented area of impact.

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

  2. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

ReaderDetailToolbar can remain active in one tab while changes to Post object can happen in another tab, making the object invalid. To avoid issues, unsubscribe to Post changes when the view disappears
@staskus staskus requested review from dvdchr and wargcm December 4, 2023 13:26
@staskus staskus added this to the 23.9 milestone Dec 4, 2023
@staskus staskus changed the title Reader: Unsubscribe to Post object changes when toolbar disappears to avoid crashes Reader: Unsubscribe from Post object changes when toolbar disappears to avoid crashes Dec 4, 2023
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 4, 2023

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr22147-1880af6
Version23.8
Bundle IDorg.wordpress.alpha
Commit1880af6
App Center BuildWPiOS - One-Offs #8054
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 4, 2023

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr22147-1880af6
Version23.8
Bundle IDcom.jetpack.alpha
Commit1880af6
App Center Buildjetpack-installable-builds #7074
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@dvdchr dvdchr self-assigned this Dec 6, 2023
Copy link
Contributor

@dvdchr dvdchr left a comment

Choose a reason for hiding this comment

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

I haven't been able to reproduce the crash so far, but I've tested the changes from this PR and didn't notice any issues with the expected flow. LGTM!

Thanks for tackling this, @staskus ! 🙇🏼‍♂️

@dvdchr dvdchr removed their assignment Dec 6, 2023
@staskus staskus merged commit 6baa736 into trunk Dec 6, 2023
@staskus staskus deleted the task/22116-reader-detail-toolbar branch December 6, 2023 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ReaderDetailToolbar] EXC_BREAKPOINT: Exception 6, Code 1, Subcode 4345966176

4 participants