GoogleChromeLabs / chromium-bidi

Implementation of WebDriver BiDi for Chromium
https://googlechromelabs.github.io/chromium-bidi/
Apache License 2.0
97 stars 32 forks source link

Unnecessary serialization of console events #2641

Open sadym-chromium opened 2 months ago

sadym-chromium commented 2 months ago

Currently, LogManager:

  1. Subscribes to Runtime.consoleAPICalled events
  2. Schedules serialization of the received events.
  3. Puts the serialization promise to the event queue.
  4. EventManager buffers the event and puts the promise to the event queue.

The step 2 requires a CDP call per element in the console message, and can be a massive in case of array with thouthands of elements was loggerd. However, the step 2 is not required until a subscription to the log is added.

sadym-chromium commented 2 months ago

Proposed solutions:

  1. Rely on http://go/webdriver:bidi-console-api-optimization.
  2. Additionally to Event and PromiseEvent, add a concept of LambdaEvent which will be evaluated only when the event has to be sent to the client. This would allow postponing the serialization till the moment they are really required.