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 unbounded growth of number media observers in Post Editor #21352

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

kean
Copy link
Contributor

@kean kean commented Aug 17, 2023

I was working on #21190 and noticed that the media observer callback was getting called more times than expected:

2023-08-17 10:19:40.856161-0400 Jetpack[79340:16077759] thumbnailReady
2023-08-17 10:19:40.856599-0400 Jetpack[79340:16084149] obserersCount: 21
2023-08-17 10:19:40.856992-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.857318-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.857671-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.858153-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.858397-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.858612-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.858811-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.859026-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.859256-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.859446-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.859637-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.859839-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.860153-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.860423-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.860650-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.860856-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048
2023-08-17 10:19:40.861054-0400 Jetpack[79340:16077759] mediathumbnailReady: -1680247048

It turned out, the longer you edit the post, the more media observers it adds. So, in my case, it was redrawing the image block 20 times instead of one 🫠

GutenbergMediaInserterHelper registers the observer on init and removes it on deinit.

To test:

  • Verify the media uploads function correctly (compare with the production version)

Regression Notes

  1. Potential unintended areas of impact: Media Uploads
  2. What I did to test those areas of impact (or what existing automated tests I relied on): n/a
  3. What automated tests I added (or what prevented me from doing so): n/a

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)

@@ -154,9 +154,6 @@ class GutenbergMediaInserterHelper: NSObject {
}

func syncUploads() {
if mediaObserverReceipt != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it meant to be mediaObserverReceipt == nil.

@kean kean changed the title Fix an issue with unbounded growth of number media observers in Post Editor Fix unbounded growth of number media observers in Post Editor Aug 17, 2023
@peril-wordpress-mobile
Copy link

Warnings
⚠️ PR is not assigned to a milestone.

Generated by 🚫 dangerJS

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 17, 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 Numberpr21352-ce6895d
Version23.0
Bundle IDorg.wordpress.alpha
Commitce6895d
App Center BuildWPiOS - One-Offs #6796
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 Aug 17, 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 Numberpr21352-ce6895d
Version23.0
Bundle IDcom.jetpack.alpha
Commitce6895d
App Center Buildjetpack-installable-builds #5836
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean kean requested review from momo-ozawa and removed request for guarani August 21, 2023 15:43
Copy link
Contributor

@momo-ozawa momo-ozawa 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! Can you update the release notes to capture this change? Thanks!

@kean
Copy link
Contributor Author

kean commented Aug 22, 2023

Nice catch! Can you update the release notes to capture this change? Thanks!

I update them right before the merge to avoid merge conflicts 😅

@kean kean force-pushed the fix/infinite-number-of-media-observers branch from 0606531 to ce6895d Compare August 22, 2023 14:57
@kean kean enabled auto-merge August 22, 2023 14:57
@kean kean merged commit d9c1024 into trunk Aug 22, 2023
@kean kean deleted the fix/infinite-number-of-media-observers branch August 22, 2023 15:32
@kean kean added this to the 23.2 milestone Aug 22, 2023
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