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

[BUG] Webkit is not working with Monaco editor #9769

Closed
kjcho-msft opened this issue Oct 26, 2021 · 13 comments
Closed

[BUG] Webkit is not working with Monaco editor #9769

kjcho-msft opened this issue Oct 26, 2021 · 13 comments
Assignees

Comments

@kjcho-msft
Copy link

Context:

  • Playwright Version: 1.15.0
  • Operating System: Windows
  • Node.js version: 14.15.1
  • Browser: WebKit

Code Snippet

You can try some samples from https://github.com/microsoft/monaco-editor-samples

or use this:

<title>browser-amd-editor</title>

Monaco Editor Sample

	<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
	<script src="https://unpkg.com/monaco-editor@latest/min/vs/loader.js"></script>
	<script>
		require.config({ paths: { vs: 'https://unpkg.com/monaco-editor@latest/min/vs' } });

		require(['vs/editor/editor.main'], function () {
			var editor = monaco.editor.create(document.getElementById('container'), {
				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
				language: 'javascript'
			});
		});
	</script>
</body>

Describe the bug
Webkit would freeze when trying to load/initialize a Monaco editor instance.
And eventually you would see this error below:

WebKitWebProcess.exe

[Main Instruction]
WebKitWebProcess.exe has stopped working

[Content]
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

@kjcho-msft kjcho-msft changed the title Webkit is not working with Monaco editor [BUG] Webkit is not working with Monaco editor Oct 26, 2021
@dgozman
Copy link
Contributor

dgozman commented Oct 27, 2021

I am able to (partially) reproduce. The following page does not load for me in windows webkit. Does not crash though, just hangs forever. WebKitWebProcess.exe leaks memory, went up to 30GB before I closed the browser.

const { chromium, webkit } = require('@playwright/test');

(async () => {
  const browser = await webkit.launch({
    headless: false,
    // devtools: true,
    // viewport: null
  });
  const page = await browser.newPage();
  await page.setContent(`
<html>
	<head>
		<title>browser-amd-editor</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	</head>
	<body>
		<h2>Monaco Editor Sample</h2>
		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>

		<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
        <script src="https://unpkg.com/monaco-editor@latest/min/vs/loader.js"></script>
		
		<script>
            require.config({ paths: { vs: 'https://unpkg.com/monaco-editor@latest/min/vs' } });

			require(['vs/editor/editor.main'], function () {
				var editor = monaco.editor.create(document.getElementById('container'), {
					value: ['function x() {', '\\tconsole.log("Hello world!");', '}'].join('\\n'),
					language: 'javascript'
				});
			});
		</script>
	</body>
</html>
  `, { timeout: 0 });
  console.log('DONE LOADING');
})();

@kjcho-msft
Copy link
Author

@dgozman @yury-s This is completely blocking our E2E tests for Webkit. Can you please reconsider the priority of this? Please let me know if you need any other information from me.

Thanks!

@fujii
Copy link

fujii commented Oct 28, 2021

There is a very large layer 1000000x1000000.
Mac and GTK WebKit support tile scrolling. I think they create tiles only for visible area.
Chrome DevTools Layer panel can't show the layer in the page.

@fujii
Copy link

fujii commented Oct 28, 2021

WinCairo's Accelerated Composting isn't mature yet.
I'd like to recommend to disable Accelerated Composting by using WKPreferencesSetAcceleratedCompositingEnabled API.

@yury-s
Copy link
Member

yury-s commented Oct 28, 2021

For the record, wetried disabling accelerated mode on windows and had to reenable it back as it broke too many sites.

@fujii
Copy link

fujii commented Oct 28, 2021

That's the reason why I recommend to use WKPreferencesSetAcceleratedCompositingEnabled API.
As far as I test, I see no such problems reported.

@kjcho-msft
Copy link
Author

@fujii do you have any instructions on how to use the API? or any sample code?

@kjcho-msft
Copy link
Author

Do I need to build a custom Webkit browser with that change? If so, I am not sure how it will work for our pipelines. Can you expose it as a browser setting?

@kjcho-msft
Copy link
Author

@fujii @yury-s do you have any suggestion on how to address this? Our E2E tests for Webkit browser are blocked by this issue.

@yury-s
Copy link
Member

yury-s commented Nov 3, 2021

Do I need to build a custom Webkit browser with that change?

Yes.

If so, I am not sure how it will work for our pipelines. Can you expose it as a browser setting?

I'll try adding a command line flag that would allow to disable accelerated compositing when launching the browser (will call WKPreferencesSetAcceleratedCompositingEnabled internally).

@yury-s
Copy link
Member

yury-s commented Nov 4, 2021

@kjcho-msft the browser patch has landed and should be available in @next version of playwright, you can pass the new flag to disable accelearated compositing in webkit on windows like below. The example above worked with the flag just fine.

  const browser = await playwright.webkit.launch({
    args: ['--disable-accelerated-compositing']
  });

@yury-s yury-s closed this as completed Nov 4, 2021
@kjcho-msft
Copy link
Author

@yury-s It looks like the fix will be in v1.17. Do you have any ETA when it will be released?

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

No branches or pull requests

5 participants