Skip to content
Open
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
9 changes: 7 additions & 2 deletions Runtime/Scripts/DataStreams/ByteDataStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ public ReadIncrementalInstruction ReadIncremental()
using var request = FFIBridge.Instance.NewRequest<ByteStreamReaderReadIncrementalRequest>();
var readIncReq = request.request;
readIncReq.ReaderHandle = (ulong)_handle.DangerousGetHandle();
request.Send();

return new ReadIncrementalInstruction(_handle);
// Subscribe before sending: chunk events are delivered directly on the FFI
// callback thread, and the FFI server emits already-buffered chunks as soon
// as it receives the request. Sending first loses any chunk emitted before
// the subscription exists.
var instruction = new ReadIncrementalInstruction(_handle);
request.Send();
return instruction;
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions Runtime/Scripts/DataStreams/TextDataStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@ public ReadIncrementalInstruction ReadIncremental()
using var request = FFIBridge.Instance.NewRequest<TextStreamReaderReadIncrementalRequest>();
var readIncReq = request.request;
readIncReq.ReaderHandle = (ulong)_handle.DangerousGetHandle();
request.Send();

return new ReadIncrementalInstruction(_handle);
// Subscribe before sending: chunk events are delivered directly on the FFI
// callback thread, and the FFI server emits already-buffered chunks as soon
// as it receives the request. Sending first loses any chunk emitted before
// the subscription exists.
var instruction = new ReadIncrementalInstruction(_handle);
request.Send();
return instruction;
}

/// <summary>
Expand Down
Loading