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

LibWeb: page crashes when opening a loading image context menu #2785

Open
1 task done
FMMazur opened this issue Dec 5, 2024 · 0 comments
Open
1 task done

LibWeb: page crashes when opening a loading image context menu #2785

FMMazur opened this issue Dec 5, 2024 · 0 comments

Comments

@FMMazur
Copy link
Contributor

FMMazur commented Dec 5, 2024

Summary

Page crashes when opening a context menu for an image if the image is a broken link or while it's loading.

As Andrew says here we could have a struct to pass more information to the context menu, to have more control of what to show in the context menu.

auto immutable_bitmap = image_element.immutable_bitmap();
bool valid = immutable_bitmap.ptr() && image_element.complete();
auto bitmap = valid ? immutable_bitmap->bitmap() : nullptr;

Page::ImageContextMenu menu {
    .valid = valid,
    .image_url = image_element.document().parse_url(image_element.src()),
    .bitmap = bitmap,
};

maybe we should have more options?

Operating system

macOS

Steps to reproduce

  1. Open any page with images
  2. Open context menu on a broken or loading image

Expected behavior

Open context menu, or at least don't crash the page.

Actual behavior

Page crashes.

URL for a reduced test case

N/A

HTML/SVG/etc. source for a reduced test case

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Broken Image</title>
</head>
<body>
    <img src="https://ladybird.org/assets/img/logo-new.webp">
    <img src="invalid.webp" style="width: 200px; height: 200px;">
</body>
</html>

Log output and (if possible) backtrace

VERIFICATION FAILED: m_ptr at /Users/fmmazur/Projects/contrib/ladybird/AK/RefPtr.h:280
0   liblagom-ak.0.0.0.dylib             0x0000000103c84e3c ak_trap + 56
1   liblagom-ak.0.0.0.dylib             0x0000000103c85140 ak_assertion_failed + 0
2   liblagom-web.0.0.0.dylib            0x00000001058c8a44 Web::EventHandler::handle_mouseup(Gfx::Point<Web::CSSPixels>, Gfx::Point<Web::CSSPixels>, unsigned int, unsigned int, unsigned int) + 2528
3   WebContent                          0x0000000102e6b1f8 WebContent::ConnectionFromClient::process_next_input_event() + 404
4   liblagom-web.0.0.0.dylib            0x00000001059146dc AK::Function<void ()>::CallableWrapper<Web::Platform::TimerSerenity::TimerSerenity()::$_0>::call() + 96
5   liblagom-core.0.0.0.dylib           0x00000001038dd404 Core::Timer::timer_event(Core::TimerEvent&) + 208
6   liblagom-core.0.0.0.dylib           0x00000001038c9340 Core::EventReceiver::dispatch_event(Core::Event&, Core::EventReceiver*) + 228
7   liblagom-core.0.0.0.dylib           0x00000001038dc138 Core::ThreadEventQueue::process() + 424
8   liblagom-core.0.0.0.dylib           0x00000001038de7bc Core::EventLoopImplementationUnix::exec() + 44
9   liblagom-core.0.0.0.dylib           0x00000001038c6eac Core::EventLoop::exec() + 72
10  WebContent                          0x0000000102e66b68 serenity_main(Main::Arguments) + 6868
11  WebContent                          0x0000000102f35960 main + 192
12  dyld                                0x000000019c5f7154 start + 2476

Screenshots or screen recordings

No response

Build flags or config settings

No response

Contribute a patch?

  • I’ll contribute a patch for this myself.
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

1 participant