-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
core(cumulative-layout-shift): experiment with new shared trace engine #15702
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96e1a0e
core(cumulative-layout-shift): calculate with shared trace engine
connorjclark 6a4f4ba
avoid node fs build error
connorjclark 30b7e6b
lint
connorjclark 6b3dd22
pr
connorjclark d3d9f48
pr
connorjclark 3f369c4
update to only try new engine for cls calc
connorjclark ab8f0b9
debugdata
connorjclark 69c03c4
tests
connorjclark 4c19cd5
huh
connorjclark 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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// @ts-nocheck | ||
/* eslint-disable */ | ||
|
||
function polyfillDOMRect() { | ||
// devtools assumes clientside :( | ||
|
||
// Everything else in here is the DOMRect polyfill | ||
// https://raw.githubusercontent.com/JakeChampion/polyfill-library/master/polyfills/DOMRect/polyfill.js | ||
|
||
(function (global) { | ||
function number(v) { | ||
return v === undefined ? 0 : Number(v); | ||
} | ||
|
||
function different(u, v) { | ||
return u !== v && !(isNaN(u) && isNaN(v)); | ||
} | ||
|
||
function DOMRect(xArg, yArg, wArg, hArg) { | ||
let x, y, width, height, left, right, top, bottom; | ||
|
||
x = number(xArg); | ||
y = number(yArg); | ||
width = number(wArg); | ||
height = number(hArg); | ||
|
||
Object.defineProperties(this, { | ||
x: { | ||
get: function () { return x; }, | ||
set: function (newX) { | ||
if (different(x, newX)) { | ||
x = newX; | ||
left = right = undefined; | ||
} | ||
}, | ||
enumerable: true | ||
}, | ||
y: { | ||
get: function () { return y; }, | ||
set: function (newY) { | ||
if (different(y, newY)) { | ||
y = newY; | ||
top = bottom = undefined; | ||
} | ||
}, | ||
enumerable: true | ||
}, | ||
width: { | ||
get: function () { return width; }, | ||
set: function (newWidth) { | ||
if (different(width, newWidth)) { | ||
width = newWidth; | ||
left = right = undefined; | ||
} | ||
}, | ||
enumerable: true | ||
}, | ||
height: { | ||
get: function () { return height; }, | ||
set: function (newHeight) { | ||
if (different(height, newHeight)) { | ||
height = newHeight; | ||
top = bottom = undefined; | ||
} | ||
}, | ||
enumerable: true | ||
}, | ||
left: { | ||
get: function () { | ||
if (left === undefined) { | ||
left = x + Math.min(0, width); | ||
} | ||
return left; | ||
}, | ||
enumerable: true | ||
}, | ||
right: { | ||
get: function () { | ||
if (right === undefined) { | ||
right = x + Math.max(0, width); | ||
} | ||
return right; | ||
}, | ||
enumerable: true | ||
}, | ||
top: { | ||
get: function () { | ||
if (top === undefined) { | ||
top = y + Math.min(0, height); | ||
} | ||
return top; | ||
}, | ||
enumerable: true | ||
}, | ||
bottom: { | ||
get: function () { | ||
if (bottom === undefined) { | ||
bottom = y + Math.max(0, height); | ||
} | ||
return bottom; | ||
}, | ||
enumerable: true | ||
} | ||
}); | ||
} | ||
|
||
globalThis.DOMRect = DOMRect; | ||
})(globalThis); | ||
} | ||
|
||
export {polyfillDOMRect}; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @ts-expect-error missing types | ||
import * as TraceEngine from '@paulirish/trace_engine'; | ||
|
||
import {polyfillDOMRect} from './polyfill-dom-rect.js'; | ||
|
||
polyfillDOMRect(); | ||
|
||
const TraceProcessor = TraceEngine.Processor.TraceProcessor; | ||
const TraceHandlers = TraceEngine.Handlers.ModelHandlers; | ||
const RootCauses = TraceEngine.RootCauses.RootCauses.RootCauses; | ||
|
||
export { | ||
TraceProcessor, | ||
TraceHandlers, | ||
RootCauses, | ||
}; |
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.
I always get mixed up on this so just correct me if I'm wrong, but isn't it less lenient?
Some events may have
had_recent_input: true
so wouldn't be counted by Chrome/DT toward the CLS total, but Lighthouse includes those events (potentially making CLS worse) because it wasn't really input, it was the emulation viewport change?edit: I guess unless it's saying it's more lenient from the perspective of the events getting filtered out, haha
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.
yeah, the filter itself is more lenient in what it allows through. It's a lot of summarize so I just have the comment defer to "the comment in
getLayoutShiftEvents
"