admin管理员组

文章数量:1122846

I noticed that Leaks instrument detects memory leaks when UIActivityViewController is presented/dismissed and when it contains a web link.

Code is as simple as:

let textToShare = "Some text"
let urlToShare = URL(string: ";)!
    
let activityViewController = UIActivityViewController(activityItems: [textToShare, urlToShare], applicationActivities: nil)

present(activityViewController, animated: true)

Here is a screenshot of Leaks. The first red check finds 25 leaks, then controller get dismissed and then the second red check finds 17 new leaks. Tested on iOS 16.4 simulator. Amount of leaks varies.

The interesting thing is if you remove links from this controller, memory leaks are gone.

Pushing this controller is also followed by these messages in debugger:

[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>

and

Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

I tested it out on a real device with iOS 18.2, same results.

Any idea why this is happening and how to prevent it?

Xcode 16.1

本文标签: swiftMemory leaks when using links in UIActivityViewControllerStack Overflow