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

Eagerly free resources on CupertinoClient.close() #1191

Merged
merged 1 commit into from
May 2, 2024
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
5 changes: 3 additions & 2 deletions pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

* Upgrade to `package:ffigen` 11.0.0.
* Bring `WebSocket` behavior in line with the documentation by throwing
`WebSocketConnectionClosed` rather `StateError` when attempting to send
`WebSocketConnectionClosed` rather than `StateError` when attempting to send
data to or close an already closed `CupertinoWebSocket`.
* Update minimum supported iOS/macOS versions to be in sync with the minimum
(best effort) supported for Flutter: iOS 12, macOS 10.14
(best effort) supported for Flutter: iOS 12, macOS 10.14.
* Eagerly free resources on `CupertinoClient.close()`.

## 1.4.0

Expand Down
8 changes: 8 additions & 0 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1613,4 +1613,12 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
onWebSocketTaskClosed: _onWebSocketTaskClosed);
return task;
}

/// Free resources related to this session after the last task completes.
/// Returns immediately.
///
/// See [NSURLSession finishTasksAndInvalidate](https://developer.apple.com/documentation/foundation/nsurlsession/1407428-finishtasksandinvalidate)
void finishTasksAndInvalidate() {
_nsObject.finishTasksAndInvalidate();
}
}
1 change: 1 addition & 0 deletions pkgs/cupertino_http/lib/src/cupertino_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class CupertinoClient extends BaseClient {

@override
void close() {
_urlSession?.finishTasksAndInvalidate();
_urlSession = null;
}

Expand Down
Loading