Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions iOS/Debugger/Core/DebuggerEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ public final class DebuggerEngine {
// MARK: - Private Methods

private func setupExceptionHandling() {
// Set up exception handling
NSSetUncaughtExceptionHandler { exception in
Self.shared.handleException(exception)
}
// Set up exception handling with a static function to avoid capturing self
NSSetUncaughtExceptionHandler(DebuggerEngine.handleUncaughtException)
}

// Static exception handler that doesn't capture self
private static func handleUncaughtException(_ exception: NSException) {
shared.handleException(exception)
}

private func handleException(_ exception: NSException) {
Expand Down
13 changes: 4 additions & 9 deletions iOS/Operations/CoreML/CoreMLManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,7 @@ final class CoreMLManager {
}
}

// First create an observer variable
var memoryObserverLocal: NSObjectProtocol?

// Set up memory pressure observer - create the observer first
// Store the observer in a local variable first
let memoryObserver = NotificationCenter.default.addObserver(
forName: UIApplication.didReceiveMemoryWarningNotification,
object: nil,
Expand All @@ -441,16 +438,14 @@ final class CoreMLManager {
}

// Remove the observer itself
if let observer = memoryObserverLocal {
NotificationCenter.default.removeObserver(observer)
}
NotificationCenter.default.removeObserver(memoryObserver)

self?.isModelLoading = false
completion?(false)
}

// Store the observer in the local variable after creating it
memoryObserverLocal = memoryObserver
// Store the observer in the array for later cleanup
memoryObservers.append(memoryObserver)

// Perform actual loading in background
predictionQueue.async { [weak self] in
Expand Down
Loading