[dotnet] [bidi] Keep events deserialization at transport layer#17212
Conversation
Review Summary by QodoMove BiDi event deserialization to transport layer for faster processing
WalkthroughsDescription• Move BiDi event deserialization from background thread to transport layer • Deserialize events immediately upon receipt with typed EventArgs objects • Simplify PendingEvent structure by removing JSON byte data • Add TryGetJsonTypeInfo method for event type lookup and validation File Changes1. dotnet/src/webdriver/BiDi/Broker.cs
|
Code Review by Qodo
1. No tests for event deserialization
|
There was a problem hiding this comment.
Pull request overview
This PR refactors BiDi event deserialization in the .NET binding, moving it from the background event-processing thread to the transport/message-receiving layer in Broker. This simplifies EventDispatcher by having it work with already-deserialized EventArgs objects instead of raw byte arrays.
Changes:
- Deserialization of event params moved from
EventDispatcher.ProcessEventsAwaiterAsynctoBroker.ProcessReceivedMessage, using a snapshotUtf8JsonReaderinstead of byte-slicing. EventDispatcherexposesTryGetJsonTypeInfoso the broker can obtain the correct type info for deserialization.PendingEventsimplified from carrying raw bytes + type info to carrying a typedEventArgs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
dotnet/src/webdriver/BiDi/EventDispatcher.cs |
Simplified EnqueueEvent to accept EventArgs, added TryGetJsonTypeInfo, renamed dictionary field |
dotnet/src/webdriver/BiDi/Broker.cs |
Moved deserialization logic here using Utf8JsonReader snapshot, replaced byte-slicing approach |
So we process incoming messages as fast as possible, letting transport layer to reuse memory (upcoming PRs).
💥 What does this PR do?
This pull request refactors how BiDi events are processed and dispatched, focusing on improving type safety and simplifying event handling. The main changes involve replacing manual byte array slicing and deserialization with direct use of typed
EventArgsobjects, and consolidating event registration logic for clarity and maintainability.🔄 Types of changes