You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[objective_c] NSInputStream doesn't support run loop scheduling #3752
The NSInputStream returned by toNSInputStream ignores scheduleInRunLoop:forMode:, never sends stream events to its delegate, and hasBytesAvailable returns YES even when no data is buffered. So a reader that schedules the stream and waits for events never receives any.
NSURLSession schedules request body streams, but because hasBytesAvailable returns YES, it calls read:maxLength on its single, process-wide com.apple.NSURLConnectionLoader thread, which waits until the Dart stream provides data. Until then, no other NSURLSession request in the process can make progress. package:cupertino_http sends StreamedRequest bodies this way.
To reproduce, add this to pkgs/objective_c/test/ns_input_stream_test.dart:
test('hasBytesAvailable when scheduled in a run loop', () {
final controller =StreamController<List<int>>();
final inputStream = controller.stream.toNSInputStream();
addTearDown(inputStream.close);
inputStream.scheduleInRunLoop(
NSRunLoop.getCurrentRunLoop(),
forMode:'kCFRunLoopDefaultMode'.toNSString(),
);
inputStream.open();
expect(inputStream.hasBytesAvailable, isFalse);
});
Activity