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 discarded quick start notification observers #20997

Merged
merged 9 commits into from
Jul 5, 2023

Conversation

crazytonyli
Copy link
Contributor

Relates to #20994.

All the notification handlers in this PR use weak self reference. That means, even though the observer and the handler block is not being released and called when those notification are emitted, the actually code may not get executed if self has already been released.

There are a few places where a stopObservingQuickStart function removes the wrong observer, which not only won't stop observing quick start, but also may incorrectly cause other notification handling code not get executed. However, I have checked all the stopObservingQuickStart call sites, all of them are called from a deinit function, so this removing wrong observers code probably doesn't actually cause any issue at the moment.

Regarding testing, I'm not sure how to test this change. Is Quick Start still an active feature? If so, how can I trigger it?

Regression Notes

  1. Potential unintended areas of impact
    None.

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

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

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: N/A

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jul 3, 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 Numberpr20997-accb98d
Version22.7
Bundle IDcom.jetpack.alpha
Commitaccb98d
App Center Buildjetpack-installable-builds #5240
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 Jul 3, 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 Numberpr20997-accb98d
Version22.7
Bundle IDorg.wordpress.alpha
Commitaccb98d
App Center BuildWPiOS - One-Offs #6214
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@staskus staskus self-requested a review July 4, 2023 07:41
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Thanks for the work!

I made a few comments, most of them are about the same thing, usage of #selector vs block observer. As I understand, we could use selector observers to avoid explicit removal of observer in deinit?

Regarding testing, I'm not sure how to test this change. Is Quick Start still an active feature? If so, how can I trigger it?

Yes, it is used. It can be triggered both with a new site and an existing site. You can check QuickStartFactory to see use cases.

1 2 3
image Simulator Screenshot - iPhone 14 Pro - 2023-07-04 at 13 54 05 image

✅ I tested and the quick start functionality continues to be working.

However, I noticed that:

  • deinit is never called anywhere, even after logout. Memory debugger shows many VCs, Cells, Services continue to be initialized when only the login view is shown. Hard for me to imagine it's intentional, so I suspect more memory leaks are in play
  • DashboardQuickActionsCardCell is always initialized and startObservingQuickStart is called regardless if quick start is actually shown or not. Again, I suspect some issues in the dashboard implementation

I'll investigate a bit more and create issues if necessary

@crazytonyli crazytonyli requested a review from staskus July 5, 2023 01:13
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Thank you for the changes! LGTM! ✅

@crazytonyli crazytonyli enabled auto-merge July 5, 2023 23:33
@crazytonyli crazytonyli merged commit 7685808 into trunk Jul 5, 2023
@crazytonyli crazytonyli deleted the fix-memory-leak-in-notification-observers-3 branch July 5, 2023 23:55
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.

3 participants