Skip to content
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

feat(trace-viewer): Add setting for display canvas content in snapshots #34010

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

agg23
Copy link
Contributor

@agg23 agg23 commented Dec 13, 2024

As discussed in #33940, this PR adds a new setting to the Trace Viewer that allows users to toggle the error-prone psuedo-display of canvas content in snapshots. By default, canvas display is reverted to the previous functionality of displaying a checkered background. If enabled, the canvas content will be extracted from the browser screenshot and displayed.

Additionally adds a Settings dialog dropdown for Trace Viewer, as to group all settings.

Trace Viewer

image

UI Mode

image
image
image

This comment has been minimized.

else
canvas.title = `Canvas contents are displayed on a best-effort basis based on viewport screenshots taken during test execution.`;
} else {
canvas.title = 'Canvas content display is disabled.';
Copy link
Contributor Author

@agg23 agg23 Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to comments/suggestions on these strings

value: shouldPopulateCanvasFromScreenshot,
set: setShouldPopulateCanvasFromScreenshot,
name: 'Display canvas content',
title: 'Attempt to display the captured canvas appearance in the snapshot preview. May not be accurate.'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to comments/suggestions on these strings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Best effort canvas element visualization." ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That string is very long. I'd prefer it be shorter so it fits better in the settings UI. I do like the content though.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

4 flaky ⚠️ [firefox-page] › page/page-evaluate.spec.ts:403:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:330:5 › launchServer › should throw when used after isConnected returns false @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/proxy.spec.ts:146:3 › should work with authenticate followed by redirect @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:205:3 › should upload multiple large files @webkit-ubuntu-22.04-node18

37322 passed, 650 skipped
✔️✔️✔️

Merge workflow run.

} else {
canvas.title = 'Canvas content display is disabled.';
}

if (isUnderTest)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs to the conditional block above.

* limitations under the License.
*/

import { useSetting } from '@web/uiUtils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a little too fine-grained to me, inline?

value: shouldPopulateCanvasFromScreenshot,
set: setShouldPopulateCanvasFromScreenshot,
name: 'Display canvas content',
title: 'Attempt to display the captured canvas appearance in the snapshot preview. May not be accurate.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Best effort canvas element visualization." ?

@@ -280,7 +280,8 @@ const TraceView: React.FunctionComponent<{
return snapshot.action || snapshot.after || snapshot.before;
}, [action]);
const snapshotUrls = React.useMemo(() => {
return snapshot ? extendSnapshot(snapshot) : undefined;
// TODO: Use actual setting. Requires settings UI to be wired up
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the patch is not complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed to me that this Recorder trace view was not complete. It needs its own settings UI to integrate the canvas setting, and the menu doesn't trivially integrate with Recorder trace view because of annoying CSS issues.

limitations under the License.
*/

.settings-toolbar-dialog {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

import { useDarkModeSetting } from '@web/theme';
import { useShouldPopulateCanvasFromScreenshot } from './settings/useShouldPopulateCanvasFromScreenshot';

export const DefaultSettingsView: React.FC<{}> = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is default settings view and how is it different from generic settings view? Put them into one file and clarify the difference?

@@ -0,0 +1,159 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something that could be introduced in a separate PR (pre-work).

value: T,
set: (value: T) => void,
title: string
value: T;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Land this little refactoring separately, pre-work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants