-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feature(trace-viewer): embedded mode support PoC #30885
feature(trace-viewer): embedded mode support PoC #30885
Conversation
0556550
to
f4181da
Compare
This comment has been minimized.
This comment has been minimized.
f4181da
to
b287930
Compare
This comment has been minimized.
This comment has been minimized.
I'm supportive for those, let me know when they are no longer drafts! |
@pavelfeldman I removed the draft, but this is still a very basic implementation just to check if the integration was possible. I found out some issues with this approach: when the trace viewer iframe gets the focus keyboard shortcuts stop working, and I ned to click outside it to open the command palette for instance. |
71029da
to
216aedb
Compare
This comment has been minimized.
This comment has been minimized.
That's unfortunate! I was rendering webviews in vscode w/o such issues. Is iframe w/ snapshot breaking it? How is service worker doing, are snapshots rendered fine? |
I tried to render the trace viewer html directly without iframe and service worker doesn't work there. Nevertheless, we can just rely on the running server instead of the service worker. The only thing I still need to figure out is on how to make the websocket work, or if not possible, on how to emulate it. |
Unfortunately, we can't. It is essential for SW to fulfill all the requests. |
I am figuring that out the hard way :( I was doing some quick and dirty tests and deactivated the sw to rely on the webserver. I thought it was already handling trace requests as a fallback, but it was not, so I had to copy & paste the service worker logic there with necessary adjustments for it to work, but I stumbled on cross-domain snapshot resources that are handled by the sw and I don't see a way out of that... I'll go back to the iframe solution and see if there's a workaround for it. |
Problem explained here, with a workaround proposal: |
That did the trick, key bindings are triggered as expected when trace viewer is focused |
This comment has been minimized.
This comment has been minimized.
packages/playwright-core/src/server/trace/viewer/traceViewer.ts
Outdated
Show resolved
Hide resolved
packages/trace-viewer/src/index.tsx
Outdated
@@ -39,5 +39,26 @@ import { WorkbenchLoader } from './ui/workbenchLoader'; | |||
setInterval(function() { fetch('ping'); }, 10000); | |||
} | |||
|
|||
if (window.parent !== window && new URL(window.location.href).searchParams.has('embedded')) { |
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.
Can we do this when we are building the content for the trace viewer instead in the extension instead?
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.
Unfortunatelly no, because this code must run inside the iframe. But maybe create an embedded.html
/ embedded.tsx
, similar to index.tsx
and uiMode.tsx
, we can just drop this code there as well as instanciating the parameterized WorkbenchLoader
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.
Unfortunatelly no, because this code must run inside the iframe.
I understand that the snapshot renderer should run in an iframe, but the app itself does not have to. Are you doing this for convenience?
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.
The app depends on the SW, and for that reason there's no easy way to render it without the iframe because webviews don't support SW
This comment has been minimized.
This comment has been minimized.
The snapshot popout link is not working ( We can either disable it (it will still work on non-embedded mode) or delegate it to the server (for instance, it can launch a playwright-controlled browser and inject the trace file for sw to load it before opening the |
I found out why I thought I needed to inject the trace file before opening snapshot.html. It's a bug: #31033 |
c0a447d
to
44c101c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -24,7 +24,8 @@ import { Workbench } from './workbench'; | |||
import { TestServerConnection } from '@testIsomorphic/testServerConnection'; | |||
|
|||
export const WorkbenchLoader: React.FunctionComponent<{ | |||
}> = () => { | |||
embedded?: boolean |
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.
embedded?: boolean | |
supportTraceDrop?: boolean |
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.
embedded
mode only hides the trace viewer header, so maybe call it hideHeader
instead?
Depends on microsoft/playwright#30885 being merged and @playwright/test being updated
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f3c2006
to
0a16783
Compare
This comment has been minimized.
This comment has been minimized.
Quick status on this:
I also tried once again to implement it without the iframe (the issues I stumbed when I first tried it were mostly caused by #31033. Even if not stable yet, I'm already confident that is possible to do it. It adds some complexity, though, because playwright server needs to serve trace resources just like service worker (we cannot rely on service worker when not rendering the trace viewer on an iframe, as explained before). You can find its current implementation here:
Let me know your thoughts if it's worth to go with this solution, or if the iframe solution is good enough. |
the iframe solution is good enough |
look forward for inspect(code gen) embedded mode |
record embedded mode |
@chensce this is for trace viewer only, no recorder functionality is covered here, for that you already have the vscode recorder. |
Ok, let's try the iframe solution. Looking at the code, I think we can improve the situation via untangling some of the existing complexities. Here is my thinking:
|
I was already addressing those two points in the EmbeddedWorkbenchLoader in my non-iframe alternative, I'll cherry-pick those changes. |
You can keep it as an iframe at first, to make changes more local. |
0a16783
to
ff303c7
Compare
Depends on microsoft/playwright#30885 being merged and @playwright/test being updated
I just updated this and vscode PRs to accomodate your suggestions. Reusing the testServer was a great tip, it simplifies a lot and it's one less process to manage. |
This comment has been minimized.
This comment has been minimized.
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.
A couple of nits and it is good to go.
Test results for "tests 1"7 flaky28400 passed, 655 skipped Merge workflow run. |
Companion PR of microsoft/playwright-vscode#483