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] action works on Safari, but fails in WebKit #5894

Closed
guettli opened this issue Mar 20, 2021 · 6 comments
Closed

[BUG] action works on Safari, but fails in WebKit #5894

guettli opened this issue Mar 20, 2021 · 6 comments

Comments

@guettli
Copy link

guettli commented Mar 20, 2021

Context:

Code Snippet

const { webkit } = require('playwright');

(async () => {
  const browser = await webkit.launch({
    headless: false
  });
  const context = await browser.newContext();

  // Open new page
  const page = await context.newPage();

  // Go to https://thomas-guettler.de/htmx-swap-err-webkit/page.html
  await page.goto('https://thomas-guettler.de/htmx-swap-err-webkit/page.html');

  // Click textarea[name="comment"]
  await page.click('textarea[name="comment"]');

  // Fill textarea[name="comment"]
  await page.fill('textarea[name="comment"]', 'foobar');

  // Click text=Save
  await page.click('text=Save');

  // ---------------------
  await context.close();
  await browser.close();
})();

Describe the bug

If I press "Save" nothing happens. But finally you should see "Great, delicious food is on its way to you"

This works with chromium. And it works with Safari on MacOS.

Please let me know if you need more info.

@yury-s
Copy link
Member

yury-s commented Mar 22, 2021

Running ~/.cache/ms-playwright/webkit-1446/pw_run.sh https://thomas-guettler.de/htmx-swap-err-webkit/page.html on linux results in a segfault for me:

(gdb) bt
#0  0x00007f52e7583a5b in WTF::Detail::CallableWrapper<WebKit::IconDatabase::loadIconForPageURL(WTF::String const&, WebKit::IconDatabase::AllowDatabaseWrite, WTF::CompletionHandler<void (WTF::RefPtr<_cairo_surface, WTF::RawPtrTraits<_cairo_surface>, WTF::DefaultRefDerefTraits<_cairo_surface> >&&)>&&)::$_3::operator()()::{lambda()#1}, void>::call() () at /home/yurys/WebKit/WebKitBuild/GTK/Release/lib/libwebkit2gtk-4.0.so.37
#1  0x00007f52e5999e80 in WTF::RunLoop::performWork() () at /home/yurys/WebKit/WebKitBuild/GTK/Release/lib/libjavascriptcoregtk-4.0.so.18
#2  0x00007f52e5a00be6 in WTF::RunLoop::RunLoop()::$_1::__invoke(void*) () at /home/yurys/WebKit/WebKitBuild/GTK/Release/lib/libjavascriptcoregtk-4.0.so.18
#3  0x00007f52e5a000fa in WTF::RunLoop::$_0::__invoke(_GSource*, int (*)(void*), void*) () at /home/yurys/WebKit/WebKitBuild/GTK/Release/lib/libjavascriptcoregtk-4.0.so.18
#4  0x00007f52eabb804e in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007f52eabb8400 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007f52eabb84a3 in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#7  0x00007f52e1329fe5 in g_application_run () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#8  0x00000000004177c7 in main ()

it is likely related. I'll try to fix that and see if the problem persists. Also the code works just fine with Playwright on macOS (with the bundled webkit version), @guettli is that what you meant by saying that it works with Safari?

@yury-s
Copy link
Member

yury-s commented Mar 22, 2021

With a quick fix for the icon loader I now see the following error printed to js console:

image

@pavelfeldman
Copy link
Member

Nothing crashes for me, but I can confirm that running this on macOS works fine, while running it on Ububtu 20 leads to the error above in console.

@pavelfeldman
Copy link
Member

pavelfeldman commented Mar 29, 2021

I think you just found a browser-specific bug in your code (htmx to be exact) with Playwright:

Tl/dr,

  • Open this page in Safari
  • Press tab several times to focus Submit
  • Press Space. It'll click but won't work. You will see error in console

Details:
Upon successful form submit, it uses document.activeElement and calls selectionStart on it. In Chromium, it is going to be <input>, because you just pressed Submit input. Same goes for WebKit on Ubuntu. Interestingly, on Safari on a Mac, it is <body> if you tap, not sure why, but probably input was swapped for another element and body became active element.

Now calling input.selectionStart on submit input in Chromium is Ok, but on WebKit it throws. So the line 2084 throws and the lines 2087-2088 that actually render the new screen never happen.

Screen Shot 2021-03-29 at 4 25 29 PM

I don't see any error handling inside the catch for this try, so the reason it works in Safari is pure luck.

@guettli
Copy link
Author

guettli commented Mar 30, 2021

@pavelfeldman thank you very much for your reply. I will talk to the htmx creators:

bigskysoftware/htmx#438

@pavelfeldman
Copy link
Member

Closing as a non-actionable bug, please feel free to file a new one and link this bug if there are remaining questions.

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

No branches or pull requests

3 participants