[webkit-changes] [WebKit/WebKit] c6de46: [iOS] Memory leak when long pressing images

Aditya Keerthi noreply at github.com
Fri Jun 2 10:11:43 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c6de46a00a2ee92ad2fd093f3e03ebbfc4b6a9e1
      https://github.com/WebKit/WebKit/commit/c6de46a00a2ee92ad2fd093f3e03ebbfc4b6a9e1
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-06-02 (Fri, 02 Jun 2023)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfo.mm

  Log Message:
  -----------
  [iOS] Memory leak when long pressing images
https://bugs.webkit.org/show_bug.cgi?id=257633
rdar://109165223

Reviewed by Megan Gardner and Wenson Hsieh.

When long pressing an image (bringing up a context menu) on iOS,
`InteractionInformationAtPosition` is sent to the UI process.

`InteractionInformationAtPosition` is used to create `WKContextMenuElementInfo`,
an API object that contains information about the element that is associated
with the context menu.

However, `WKContextMenuElementInfo` is backed by an `API::ContextMenuElementInfo`.
Like all objects conforming to `WKObject`, the backing object is stored as a
reference. Consequently, the backing object is not automatically destroyed once
`WKContextMenuElementInfo` is deallocated. Consequently, a memory leak occurs
after `WKContextMenuElementInfo` is deallocated.

To fix, implement `-[WKContextMenuElementInfo dealloc]` and explicitly destroy
the backing object.

* Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfo.mm:
(-[WKContextMenuElementInfo dealloc]):

Implement `-dealloc`, matching other `WKObject`s.

Canonical link: https://commits.webkit.org/264833@main




More information about the webkit-changes mailing list