Skip to content

Declare a delegate property as a weak reference in WebKitViewController#21051

Merged
crazytonyli merged 5 commits intotrunkfrom
weak-delegate-violation-fixes-1
Jul 19, 2023
Merged

Declare a delegate property as a weak reference in WebKitViewController#21051
crazytonyli merged 5 commits intotrunkfrom
weak-delegate-violation-fixes-1

Conversation

@crazytonyli
Copy link
Copy Markdown
Contributor

Relates to #21050.

The same property is declared as weak references in

@property (nonatomic, weak) id<WebNavigationDelegate> navigationDelegate;

@objc weak var navigationDelegate: WebNavigationDelegate?

I don't see why we should not declare it as a weak reference in WebKitViewController.

Also, this property causes a memory leak in Themes. Here are the steps to reproduce the memory leak.

  1. Add a deinit function to ThemeBrowserViewController and add a breakpoint in this function.
  2. Launch the app from Xcode.
  3. Navigate to My Sites -> Menu -> Themes -> Customize.
  4. Close the opened web view.
  5. Xcode should stop at the breakpoint, but it doesn't.

Regression Notes

  1. Potential unintended areas of impact
    None. ThemeWebNavigationDelegate is the only type that implements the WebNavigationDelegate protocol.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Verified the issue can no longer be reproduced on this PR.

  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

@crazytonyli crazytonyli added this to the 22.9 milestone Jul 11, 2023
@crazytonyli crazytonyli requested review from jkmassel and mokagio July 11, 2023 03:57
@crazytonyli crazytonyli self-assigned this Jul 11, 2023
@wpmobilebot
Copy link
Copy Markdown
Contributor

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 Numberpr21051-7b35097
Version22.7
Bundle IDorg.wordpress.alpha
Commit7b35097
App Center BuildWPiOS - One-Offs #6286
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented Jul 11, 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 Numberpr21051-51b3e8d
Version22.8
Bundle IDcom.jetpack.alpha
Commit51b3e8d
App Center Buildjetpack-installable-builds #5422
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@crazytonyli crazytonyli enabled auto-merge July 19, 2023 01:07
@crazytonyli crazytonyli merged commit 0638954 into trunk Jul 19, 2023
@crazytonyli crazytonyli deleted the weak-delegate-violation-fixes-1 branch July 19, 2023 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants