-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: upgrade trace_engine and drop manually written types #15810
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,13 @@ | |
Samples: TraceEngine.TraceHandlers.Samples, | ||
Screenshots: TraceEngine.TraceHandlers.Screenshots, | ||
}); | ||
await engine.parse(traceEvents); | ||
return engine.data; | ||
// eslint-disable-next-line max-len | ||
await engine.parse(/** @type {import('@paulirish/trace_engine').Types.TraceEvents.TraceEventData[]} */ ( | ||
traceEvents | ||
)); | ||
// TODO: use TraceEngine.TraceProcessor.createWithAllHandlers above. | ||
return /** @type {import('@paulirish/trace_engine').Handlers.Types.TraceParseData} */( | ||
engine.data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will follow up with this change. Didn't want a behavior change with this patch. |
||
} | ||
|
||
/** | ||
|
@@ -61,7 +66,11 @@ | |
} | ||
} | ||
|
||
return TraceEngineResult.runTraceEngine(traceEvents); | ||
const result = await TraceEngineResult.runTraceEngine(traceEvents); | ||
if (!result) { | ||
throw new Error('null trace engine result'); | ||
} | ||
return result; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,26 +32,33 @@ | |
// nodeIds if the DOM domain was enabled before this gatherer, invoke it to be safe. | ||
await driver.defaultSession.sendCommand('DOM.getDocument', {depth: -1, pierce: true}); | ||
|
||
/** @type {import('@paulirish/trace_engine').RootCauses.RootCauses.RootCauseProtocolInterface} */ | ||
const protocolInterface = { | ||
/** @param {string} url */ | ||
// eslint-disable-next-line no-unused-vars | ||
getInitiatorForRequest(url) { | ||
return null; | ||
}, | ||
/** @param {number[]} backendNodeIds */ | ||
/** @param {import('@paulirish/trace_engine/generated/protocol.js').DOM.BackendNodeId[]} backendNodeIds */ | ||
async pushNodesByBackendIdsToFrontend(backendNodeIds) { | ||
const response = await driver.defaultSession.sendCommand( | ||
'DOM.pushNodesByBackendIdsToFrontend', {backendNodeIds}); | ||
return response.nodeIds; | ||
const nodeIds = | ||
/** @type {import('@paulirish/trace_engine/generated/protocol.js').DOM.NodeId[]} */( | ||
response.nodeIds); | ||
return nodeIds; | ||
}, | ||
/** @param {number} nodeId */ | ||
/** @param {import('@paulirish/trace_engine/generated/protocol.js').DOM.NodeId} nodeId */ | ||
async getNode(nodeId) { | ||
try { | ||
const response = await driver.defaultSession.sendCommand('DOM.describeNode', {nodeId}); | ||
// This always zero, so let's fix it here. | ||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1515175 | ||
response.node.nodeId = nodeId; | ||
return response.node; | ||
const node = | ||
/** @type {import('@paulirish/trace_engine/generated/protocol.js').DOM.Node} */( | ||
response.node); | ||
return node; | ||
} catch (err) { | ||
if (err.message.includes('Could not find node with given id')) { | ||
// TODO: when injecting an iframe, the engine gets the node of that frame's document element. | ||
|
@@ -64,7 +71,8 @@ | |
// When this is fixed, remove this try/catch. | ||
// Note: this could be buggy by giving the wrong node detail if a node id meant for a non-main frame | ||
// happens to match one from the main frame ... which is pretty likely... | ||
return null; | ||
// TODO: fix trace engine type to allow returning null. | ||
return /** @type {any} */(null); | ||
} | ||
throw err; | ||
} | ||
|
@@ -79,17 +87,20 @@ | |
return []; | ||
} | ||
}, | ||
/** @param {number} nodeId */ | ||
/** @param {import('@paulirish/trace_engine/generated/protocol.js').DOM.NodeId} nodeId */ | ||
async getMatchedStylesForNode(nodeId) { | ||
try { | ||
const response = await driver.defaultSession.sendCommand( | ||
'CSS.getMatchedStylesForNode', {nodeId}); | ||
return response; | ||
} catch { | ||
return []; | ||
return {...response, getError() {}}; | ||
} catch (err) { | ||
return /** @type {any} */({getError() { | ||
return err.toString(); | ||
}}); | ||
} | ||
}, | ||
/** @param {string} url */ | ||
// @ts-expect-error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you add a comment explaining this
connorjclark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line no-unused-vars | ||
async fontFaceForSource(url) { | ||
return null; | ||
|
@@ -104,6 +115,8 @@ | |
const layoutShiftEvents = traceEngineResult.LayoutShifts.clusters.flatMap(c => c.events); | ||
for (const event of layoutShiftEvents) { | ||
const r = await rootCausesEngine.layoutShifts.rootCausesForEvent(traceEngineResult, event); | ||
if (!r) continue; | ||
|
||
for (const cause of r.fontChanges) { | ||
// TODO: why isn't trace engine unwrapping this promise ... | ||
cause.fontFace = await cause.fontFace; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relevant chat thread:
shrugz.