mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Do not serialize remote objects unless needed
This patch stops serializing console API arguments unless there are listeners of the 'console' event in puppeteer. This saves quite a lot CPU cycles. Fixes #117.
This commit is contained in:
@@ -232,6 +232,10 @@ class Page extends EventEmitter {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!this.listenerCount(Page.Events.Console)) {
|
||||
event.args.map(arg => helper.releaseObject(this._client, arg));
|
||||
return;
|
||||
}
|
||||
let values = await Promise.all(event.args.map(arg => helper.serializeRemoteObject(this._client, arg)));
|
||||
this.emit(Page.Events.Console, ...values);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user