Commit graph

2404 commits

Author SHA1 Message Date
Liav A 40a8b009db DynamicLoader: Add an option to list all ELF loaded dependencies
This actually allows us to re-introduce the ldd utility as a symlink to
our dynamic loader, so now ldd behaves exactly like on Linux - it will
load all dynamic dependencies for an ELF exectuable.

This has the advantage that running ldd on an ELF executable will
provide an exact preview of how the order in which the dynamic loader
loads the executable and its dependencies.
2024-05-14 15:42:42 -06:00
Liav A 56790098ea Utilities: Rename ldd => elfdeps
As a preparation to introducing ldd as a symlink to /usr/lib/Loader.so
we rename the ldd utility to be elfdeps, at its sole purpose is to list
ELF object dependencies, and not how the dynamic loader loads them.
2024-05-14 15:42:42 -06:00
Liav A 5b34b4af14 Utilities: Merge the gunzip utility with gzip
Now both /bin/zcat and /bin/gunzip are symlinks to /bin/gzip, and we
essentially running it in decompression mode through these symlinks.

This ensures we don't maintain 2 versions of code to decompress Gzipped
data anymore, and handle the use case of gzipped-streaming input only
once in the codebase.
2024-05-14 12:35:25 -06:00
Lucas CHOLLET cd486a7040 image: Support exporting GIF files 2024-05-14 12:33:53 -06:00
Nico Weber e2336e2099 LibGfx+animation: Only store changed pixels in animation frames
For example, for 7z7c.gif, we now store one 500x500 frame and then
a 94x78 frame at (196, 208) and a 91x78 frame at (198, 208).

This reduces how much data we have to store.

We currently store all pixels in the rect with changed pixels.
We could in the future store pixels that are equal in that rect
as transparent pixels. When inputs are gif files, this would
guaranteee that new frames only have at most 256 distinct colors
(since GIFs require that), which would help a future color indexing
transform. For now, we don't do that though.

The API I'm adding here is a bit ugly:

* WebPs can only store x/y offsets that are a multiple of 2. This
  currently leaks into the AnimationWriter base class.
  (Since we potentially have to make a webp frame 1 pixel wider
  and higher due to this, it's possible to have a frame that has
  <= 256 colors in a gif input but > 256 colors in the webp,
  if we do the technique above.)

* Every client writing animations has to have logic to track
  previous frames, decide which of the two functions to call, etc.

This also adds an opt-out flag to `animation`, because:

1. Some clients apparently assume the size of the last VP8L
   chunk is the size of the image
   (see https://github.com/discord/lilliput/issues/159).

2. Having incremental frames is good for filesize and for
   playing the animation start-to-end, but it makes it hard
   to extract arbitrary frames (have to extract all frames
   from start to target frame) -- but this is mean tto be a
   delivery codec, not an editing codec. It's also more vulnerable to
   corrupted bytes in the middle of the file -- but transport
   protocols are good these days.
   (It'd also be an idea to write a full frame every N frames.)

For https://giphy.com/gifs/XT9HMdwmpHqqOu1f1a (an 184K gif),
output webp size goes from 21M to 11M.

For 7z7c.gif (an 11K gif), output webp size goes from 2.1M to 775K.

(The webp image data still isn't compressed at all.)
2024-05-14 13:43:03 -04:00
Nico Weber 6c79efcae4 LibGfx: Move AnimationWriter to its own file
No behavior change.
2024-05-14 13:43:03 -04:00
Nico Weber 3a4e0c2804 LibGfx+Utilities: Add animation utility, make it write animated webps
The high-level design is that we have a static method on WebPWriter that
returns an AnimationWriter object. AnimationWriter has a virtual method
for writing individual frames. This allows streaming animations to disk,
without having to buffer up the entire animation in memory first.
The semantics of this function, add_frame(), are that data is flushed
to disk every time the function is called, so that no explicit `close()`
method is needed.

For some formats that store animation length at the start of the file,
including WebP, this means that this needs to write to a SeekableStream,
so that add_frame() can seek to the start and update the size when a
frame is written.

This design should work for GIF and APNG writing as well. We can move
AnimationWriter to a new header if we add writers for these.

Currently, `animation` can read any animated image format we can read
(apng, gif, webp) and convert it to an animated webp file.

The written animated webp file is not compressed whatsoever, so this
creates large output files at the moment.
2024-05-11 15:43:02 -04:00
Marios Prokopakis eecede20ac ping: Implement waittime
Specify the time in seconds to wait for a reply for each packet sent.
Replies received out of order will not be printed as replied but they
will be considered as replied when calculating statistics. Setting it
to 0 means infinite timeout.
2024-05-09 13:13:20 -06:00
Marios Prokopakis b3658c5706 ping: Implement flood ping mode
In flood ping mode, the time interval between each request is set
to zero to provide a rapid display of how many packets are being
dropped. For each request a period '.' is printed, while for every
reply a backspace is printed.
2024-05-09 13:13:20 -06:00
Marios Prokopakis 90f5e5139f ping: Implement adaptive ping mode
In adaptive ping mode, the interval between each ping request
adapts to the RTT.
2024-05-09 13:13:20 -06:00
implicitfield f5a74d7141 Utilities: Add fusermount
This only contains the bare minimum amount of functionality required
by libfuse.
2024-05-07 16:54:27 -06:00
Nico Weber d04f9cf3c8 LibGfx+image: Add scaffolding for writing webp files 2024-05-06 17:32:19 +02:00
Andreas Kling c8821cf8e0 js: Don't try to call a null Function on SIGINT
This stops `js` from asserting when pressing ^C in the middle of
executing a long-running script.
2024-05-04 13:56:13 +02:00
Timothy Flynn 398ae75f9a Ladybird+LibWebView: Introduce a cache for cookies backed by SQL storage
Now that the chrome process is a singleton on all platforms, we can
safely add a cache to the CookieJar to greatly speed up access. The way
this works is we read all cookies upfront from the database. As cookies
are updated by the web, we store a list of "dirty" cookies that need to
be flushed to the database. We do that synchronization every 30 seconds
and at shutdown.

There's plenty of room for improvement here, some of which is marked
with FIXMEs in the CookieJar.

Before these changes, in a SQL database populated with 300 cookies,
browsing to https://twinings.co.uk/ WebContent spent:

    19,806ms waiting for a get-cookie response
    505ms waiting for a set-cookie response

With these changes, it spends:

    24ms waiting for a get-cookie response
    15ms waiting for a set-cookie response
2024-05-01 07:06:26 +02:00
Liav A. 476b3703fd Utilities/mount: Resolve regression on mounting non-storage-backed FSes
Without this patch, we fail on manually mounting RAMFS (which I tested
for) but any filesystem that is not backed by actual storage will fail.
This bug was introduced in 0739b5df11 and
now is resolved by checking if the source fd is negative, to avoid fail
of the fstat call on it.
2024-04-30 06:03:10 -06:00
Tim Ledbetter 1b1f27bdfb sort: Avoid unnecessary copies when hashing Line objects 2024-04-30 13:22:56 +02:00
Tim Ledbetter 5764356cae sort: Allow sorting of arbitrarily long lines 2024-04-30 13:22:56 +02:00
Liav A. 37d62c16f8 Utilities: Initialize raw variables to default values in some utilities 2024-04-30 01:30:38 +02:00
dgaston 342b358341 Utilities: Make uniq behavior consistent with coreutils
The main difference was that our implementation was writing
the final line of a series of repeated lines, whereas the
spec says "The second and succeeding copies of repeated adjacent
input lines shall not be written."

Additionally, there was a mistake in the -f flag implementation
causing the number of fields skipped to be one greater than
required.
2024-04-27 16:33:27 -06:00
dgaston 1d932d3ebf Utilities: Fix off by one error in uniq
Flags that rely on counting lines (-c and -d) were
producing results that were off by one. This is fixed
by initializing the `count` variable to 1, which is
consistent with behavior in the main loop, where it
is reset to 1 when lines don't match.
2024-04-27 16:33:27 -06:00
dgaston 82887473d2 Utilities: Allow uniq to work on lines of arbitrary length
Calls to `read_line` are replaced with `read_line_with_resize`
and `swap`s of StringViews, which assume a consistent location
of the underlying ByteBuffers, are replaced. A test file has
been added for uniq, which includes a test case for long lines.
2024-04-27 16:33:27 -06:00
Dan Klishch 7b88363490 Meta+Userland: Make LibELF a proper library on Serenity
Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
2024-04-26 19:08:13 -06:00
Timothy Flynn eb990fcecd sql: Use Core::Process facilities to spawn singleton processes 2024-04-24 15:51:58 -06:00
Timothy Flynn fecd08ce64 Everywhere: Remove 'clang-format off' comments that are no longer needed 2024-04-24 16:50:01 -04:00
ronak69 b25d220a2c headless-browser: Call platform_init() for path of resources folder
For `AK_OS_SERENITY`, the root path of the resources folder is "/res";
but otherwise it should be the `s_serenity_resource_root` variable set
in `platform_init()`.

However, a path provided on the command line, will override the default
path in both of those cases.

This change also makes sure that `RequestServer` can find the
certificates file `serenity/Build/lagom/share/Lagom/ladybird/cacert.pem`
2024-04-24 10:21:20 +02:00
Andrew Kaster 1c3f11a5a6 Userland: Remove remaining callers of synchronous ImageDecoder API
Most of these now just await the image decoding, equivalent (ish) to
the old behavior. A more async-aware refactor should happen some time
in the future.
2024-04-23 12:32:04 -06:00
Timothy Flynn f16f89eb32 Ladybird+LibWebView: Move SQLServer launcher to Ladybird
It previously resided in LibWebView to hide the details of launching a
singleton process. That functionality now lives in LibCore. By moving
this to Ladybird, we will be able to register the process with the task
manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn 76af4503c1 LibCore: Return the singleton process's PID along with its IPC client
The PID will be used for Ladybird's task manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn bf50881e61 LibCore+LibSQL+LibWebView: Move launching a singleton process to LibCore
This just moves the code to launch a single process such as SQLServer to
LibCore. This will allow re-using this feature for other processes, and
will allow moving the launching of SQLServer to Ladybird.
2024-04-22 14:46:10 -06:00
Shannon Booth 1ec6399c00 Everywhere: Remove uneeded short option argument where possible 2024-04-22 08:10:08 +02:00
Dan Klishch d8119c4b4a LibLocale: Statically link LibLocaleData into LibLocale 2024-04-21 13:34:04 -06:00
Andreas Kling 4db1712f90 LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated
These objects had confusing ownership semantics. Let's just throw them
all on the GC heap and stop worrying about it.
2024-04-21 09:12:25 +02:00
Andreas Kling cd6a458e83 headless-browser: Add -G option to dump GC graph on exit
This will be useful in tracking down the list of GC leaks that occur
across a run of our test suite.
2024-04-21 09:12:25 +02:00
Andrew Kaster 5e1d678bae Ladybird+Userland: Remove use of unnecessary fd passing socket concept
Now that LibIPC is using SCM_RIGHTS properly, we can go back to only
having one socket laying around when needing to transfer fds to peers.
2024-04-19 16:38:55 -04:00
Dan Klishch 5ed7cd6e32 Everywhere: Use east const in more places
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
2024-04-19 06:31:19 -04:00
Andrew Kaster c87e32154a Ladybird+headless-browser: Make RequestServer single instance on Lagom
Co-Authored-By: Timothy Flynn <trflynn89@pm.me>
2024-04-17 10:09:49 -04:00
Andreas Kling 1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Space Meyer 106d4636a4 Revert "Kernel+SystemServer: Make KCOVDevice a character device"
This reverts commit 9dbec601b0.

For KCOV to be performant (or at least not even slower) we need to
mmap the PC buffer from both user and kernel space at the same time.
You can't mmap a character device, so this change didn't make sense.

Plus even if we did invent a new method to exfiltrate the coverage
information out of the kernel, it would be incompatible with existing
kernel fuzzers. That would be kind of annoying. 🙃
2024-04-15 21:16:22 -06:00
Dan Klishch 50911e6f96 Utilities/w: Work around Clang 18 bug with templated lambda + Variant
This was missed in 6f972c1 since this file is not compiled as a part of 
a Lagom build.
2024-04-15 17:58:47 -06:00
Shannon Booth 0090b916dd LibJS: Make ParserError::to_string infallible 2024-04-05 20:01:37 -04:00
Fabian Dellwing e511c553a8 tail: Implement byte mode into tail
This works exactly the same as with lines but with bytes instead.
2024-04-05 15:30:41 -06:00
Fabian Dellwing 91e944d793 tail: Choose correct line to output from
Previously we did not match the behaviour of coreutils in our from
start modus and some edge cases with 0 and 1 lines were broken.
2024-04-05 15:30:41 -06:00
Timothy Flynn 683c08744a Userland: Avoid some conversions from rvalue strings to StringView
These are all actually fine, there is no UAF here. But once e.g.
`ByteString::view() &&` is deleted, these instances won't compile.
2024-04-04 11:23:21 +02:00
Timothy Flynn c23060e21b Userland: Avoid some now-unneeded explicit conversions to Bytes 2024-04-04 11:23:21 +02:00
ronak69 9454346341 headless-browser: Don't forget to load webpage before taking screenshot
For the normal non-test use case of headless-browser, the function
`load_page_for_screenshot_and_exit()` didn't actually load the requested
webpage in the `WebView`, resulting in an all white pixels screenshot.
2024-03-28 08:01:33 +01:00
Nico Weber 2e142105c9 Fuzzers: Add JPEG2000 fuzzer 2024-03-25 20:35:00 +01:00
Timothy Flynn aad110ec7e base64: Map input files into memory for reading
We do the same thing with the gzip utility for performance.

This reduces the runtime of `./bin/base64 enwik8 >/dev/null` from
0.428s to 0.303s.

This reduces the runtime of `./bin/base64 -d enwik8.base64 >/dev/null`
from 0.632s to 0.469s.

(enwik8 is a 100MB test file from http://mattmahoney.net/dc/enwik8.zip)
2024-03-21 15:53:46 +01:00
Nico Weber 1ae174e380 image: Add a --crop option
You can now run

    image -o out.png Tests/LibGfx/test-inputs/bmp/bitmap.bmp \
        --crop 130,86,108,114

and end up with the nose part of that image in out.png.
2024-03-20 13:58:23 +01:00
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Timothy Flynn 1f44c9468a LibCore: Replace MIME type description lookup with a more generic method
Rather than adding a bunch of `get_*_from_mime_type` functions, add just
one to get the Core::MimeType instance. We will need multiple fields at
once in Browser.
2024-03-16 08:42:33 +01:00