Commit graph

33 commits

Author SHA1 Message Date
Timothy Flynn 1c4dd0caad Ladybird+LibWeb+WebConent: Drive audio in Ladybird off the main thread
The main thread in the WebContent process is often busy with layout and
running JavaScript. This can cause audio to sound jittery and crack. To
avoid this behavior, we now drive audio on a secondary thread.

Note: Browser on Serenity uses AudioServer, the connection for which is
already handled on a secondary thread within LibAudio. So this only
applies to Lagom.

Rather than using LibThreading, our hands are tied to QThread for now.
Internally, the Qt media objects use a QTimer, which is forbidden from
running on a thread that is not a QThread (the debug console is spammed
with messages pointing this out). Ideally, in the future AudioServer
will be able to run for non-Serenity platforms, and most of this can be
aligned with the Serenity implementation.
2023-06-21 06:14:15 +02:00
Andreas Kling 9c568282dc Ladybird+LibJS: Add CLI option to run browser with LibJS bytecode VM
This required quite a bit of plumbing, but now you can run

    ladybird --use-bytecode
2023-06-17 14:16:45 +02:00
Timothy Flynn a34e369252 Ladybird+LibWeb+WebContent: Create a platform plugin for playing audio
This creates (and installs upon WebContent startup) a platform plugin to
play audio data.

On Serenity, we use AudioServer to play audio over IPC. Unfortunately,
AudioServer is currently coupled with Serenity's audio devices, and thus
cannot be used in Ladybird on Lagom. Instead, we use a Qt audio device
to play the audio, which requires the Qt multimedia package.

While we use Qt to play the audio, note that we can still use LibAudio
to decode the audio data and retrieve samples - we simply send Qt the
raw PCM signals.
2023-06-13 06:14:01 +02:00
Lucas CHOLLET 8c34959b53 AK: Add the Input word to input-only buffered streams
This concerns both `BufferedSeekable` and `BufferedFile`.
2023-05-09 11:18:46 +02:00
martinfalisse c719a542c5 LibWeb: Add --layout-test-mode flag to HeadlessBrowser
The `layout-test-mode` flag changes the font to be SerenitySans as this
is the font used for layout tests for cross-platform compatibility of
tests.
2023-05-08 14:47:52 +02:00
martinfalisse 00e446facd Ladybird: Move arguments parsing before FontPluginQt init
In a future commit will pass arguments parsed to the FontPluginQt
constructor.
2023-05-08 14:47:52 +02:00
Timothy Flynn 4dcdc3bd25 Ladybird: Prohibit GUI interaction of the WebContent process on macOS
The WebContent process behaves a bit awkwardly on macOS. When we launch
the process, we have to create a QGuiApplication to access system fonts.
But on macOS, doing so creates an entry in the Dock, and also causes the
WebContent to be focused. So if you enter cmd+Q without first focusing
the Ladybird GUI, WebContent is closed, while the Ladybird process keeps
running.
2023-04-27 07:26:05 +02:00
Andreas Kling 7b963e1e98 LibCore+Ladybird: Add EventLoopManager interface for persistent state
Things such as timers and notifiers aren't specific to one instance of
Core::EventLoop, so let's not tie them down to EventLoopImplementation.

Instead, move those APIs + signals & a few other things to a new
EventLoopManager interface. EventLoopManager also knows how to create a
new EventLoopImplementation object.
2023-04-25 18:01:35 +02:00
Andreas Kling 1c6c3685c4 Ladybird: Remove Web::Platform plugins for Qt in favor of LibCore
Now that the Core::EventLoop is driven by a QEventLoop in Ladybird,
we don't need to patch LibWeb with Web::Platform plugins.

This patch removes EventLoopPluginQt and TimerQt.

Note that we can't just replace the Web::Platform abstractions with
LibCore stuff immediately, since the Web::Platform APIs use
JS::SafeFunction for callbacks.
2023-04-25 14:48:40 +02:00
Andreas Kling 3494c2382d Ladybird: Run the Core::EventLoop with a Qt backend
This patch adds EventLoopImplementationQt which is a full replacement
for the Core::EventLoopImplementationUnix that uses Qt's event loop
as a backend instead.

This means that Core::Timer, Core::Notifier, and Core::Event delivery
are all driven by Qt primitives in the Ladybird UI and WC processes.
2023-04-25 14:48:40 +02:00
Andreas Kling 411d36719e LibCore: Simplify Core::Notifier by only allowing one event type
Not a single client of this API actually used the event mask feature to
listen for readability AND writability.

Let's simplify the API and have only one hook: on_activation.
2023-04-25 14:48:40 +02:00
Timothy Flynn 8fe846eb7f Ladybird: Define AK_DONT_REPLACE_STD via CMake rather than in every file 2023-04-24 14:49:04 +02:00
Timothy Flynn 5089766af6 Browser+Ladybird+LibWeb: Port content filters to String 2023-04-22 12:32:40 +02:00
Timothy Flynn 76ae60da15 Browser+Ladybird+LibWeb: Prevent infinite growth of content filters
We never clear content filters on either end of the Browser-WebContent
IPC connection. So when the filters change, we re-append all filters to
the Vector holding them. This incidentally makes it impossible to remove
a filter.

Change both sides to clear their filter lists when receiving a new set
of filters.
2023-04-22 12:32:40 +02:00
Timothy Flynn 1ffd533ea2 Ladybird: Propagate autoplay settings to the WebContent process 2023-04-18 16:30:02 +02:00
Cameron Youell 1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
Timothy Flynn 6e1b5b541a LibWeb: Move initialization of the MainThreadVM to WebContent's main()
It is a fallible operation, so this lets us abort early if it fails.
2023-03-17 16:39:08 +00:00
Timothy Flynn 700ad6bf35 WebContent+LibWebView: Consolidate the way browsers connect to WebDriver
Currently, on Serenity, we connect to WebDriver from the browser-side of
the WebContent connection for both Browser and headless-browser.

On Lagom, we connect from within the WebContent process itself, signaled
by a command line flag.

This patch changes Lagom browsers to connect to WebDriver the same way
that Serenity browsers do. This will ensure we can do other initializers
in the same order across all platforms and browsers.
2023-03-16 15:02:41 +00:00
Tim Schumacher 606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher a96339b72b LibCore: Move Stream-based sockets into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Timothy Flynn e5192073d9 Ladybird/WebDriver: Move to using local socket files for WebDriver IPC
This allows us to use standard Serenity IPC infrastructure rather than
manually creating FD-passing sockets. This also lets us use Serenity's
WebDriver Session class, removing the copy previously used in Ladybird.
This ensures any changes to Session in the future will be picked up by
Ladybird for free.
2022-12-25 07:58:58 -07:00
Andreas Kling e54932ee73 Ladybird: Fix build after ConsoleGlobalEnvironmentExtensions rename 2022-12-25 07:58:58 -07:00
Linus Groh 5a5c4f079b Ladybird: Update for AK::{String => DeprecatedString} rename 2022-12-25 07:58:58 -07:00
Timothy Flynn a1e380cc38 Ladybird/WebDriver: Support running headless WebDriver sessions
This adds a dependency from WebDriver to Lagom's headless-browser to be
used if the client's required capabilities indicate to do so.
2022-12-25 07:58:58 -07:00
Timothy Flynn 4031630b49 Ladybird: Construct a WebDriverConnection when instructed to do so
The WebDriver will pass the --webdriver-fd-passing-socket command line
option when it launches Ladybird. Forward this flag onto the WebContent
process, where it will create the WebDriverConnection for IPC.
2022-12-25 07:58:58 -07:00
Timothy Flynn 7021d30288 Ladybird: Foward the WebContent passing socket FD by command line
Rather than needing to set another environment variable for WebDriver's
passing socket, let's forward these FDs by command line. This also moves
the creation of the WebContent connection to a helper function so that
the WebDriver connection can re-use it.
2022-12-25 07:58:58 -07:00
Timothy Flynn 5d0ab45ff4 Ladybird: Add new WebContent source file for WebDriver endpoints 2022-12-25 07:58:58 -07:00
Andreas Kling 385c12c8b6 Ladybird: Add subclass of WebSocket::WebSocketImpl using Qt networking 2022-12-25 07:58:58 -07:00
Linus Groh 216192143e Ladybird: Clean up linked libraries
- Add Qt::Core, Qt::Gui, LibGfx, LibIPC, and LibJS to the ladybird
  target, remove LibGL, LibSoftGPU, and LibWebSocket
- Add LibJS to the WebContent target, remove LibWebView
- Order them properly :^)

Regressed in https://github.com/SerenityOS/serenity/pull/15746.
Fixes #108.
2022-12-25 07:58:58 -07:00
Andrew Kaster 6fff03713c Ladybird: Ensure that installed ladybird can launch WebContent process
Always call platform_init after there's a QApplication, because in the
installed configuration that's how we find the resources.

Try QCoreApplication::applicationDirPath() after looking in ./WebContent
for the WebContent process. In an installed configuration, ladybird and
WebContent will both be in $PREFIX/bin.

Add install rules for WebContent and its linked libraries, for if they
ever differ from ladybird's.
2022-12-25 07:58:58 -07:00
Andreas Kling 2b1d294dc6 Ladybird: Let Lagom build the IPC endpoints for WebContent 2022-12-25 07:58:58 -07:00
Andreas Kling 26a7ea0e0f Ladybird: Render web content in a separate process :^)
This patch brings over the WebContent process over from SerenityOS
to Ladybird, along with a new WebContentView widget that renders
web content in a separate process.

There's a lot of jank and FIXME material here, notably I had to re-add
manually pumped Core::EventLoop instances on both sides, in order to get
the IPC protocol running. This introduces a lot of latency and we should
work towards replacing those loops with improved abstractions.

The WebContent process is built separately here (not part of Lagom) and
we provide our own main.cpp for it. Like everything, this can be better
architected, it's just a starting point. :^)
2022-12-25 07:58:58 -07:00