Commit Graph

71 Commits (master)

Author SHA1 Message Date
Ashod Nakashian d57baeb906 wsd: reduce directives for unused variable supression
We use [[maybe_unused]] to reduce explicit supression
especially under compile-time directives.

Change-Id: Ic5f3f3227a80efe52097cb35520d05b9cdaacb42
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-09 12:37:19 -05:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Skyler Grey ee57d3af74 Fix tile dumping when /tmp is not temporary directory
On iOS, each app has its own sandbox which has a temporary directory.
The FileUtil::getSysTempDirectoryPath() method successfully gets this
directory and we create a tiledump directory under it. Sadly, we then
try to write to /tmp regardless of where the temporary directory is.

This commit makes us also write our file in the directory returned by
FileUtil::getSysTempDirectoryPath()

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: Ic8425cb94d1d85ac9c77212eb84d0ca7c46cd34e
2023-10-10 08:24:21 +00:00
Michael Meeks fde98db394 Factor out CPU RLE into a function with similar signature.
Performance testing suggests that:
 + dense text this is 2x faster.
 + 'hello world' text this is 1.7x faster.

Change-Id: I4ff940663c44d0b22c9187deb4ee397a9d9953b0
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-09-25 16:55:04 +01:00
Michael Meeks 743fa7d91f Use a LUT and SIMD packing logic to accelerate RLE pixel copy.
Change-Id: I6874f1b33acf6f0f3c72c86f9fbe232e1f5a560a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-09-25 16:55:04 +01:00
Caolán McNamara 42e98bb2e4 experimentally bootstrap something using avx2 to generate bitmap
just enough to get the same results as before

https://github.com/CollaboraOnline/online/issues/7165

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I109c9b8f1e7935782c72e0179aa0ed48712eadb6
2023-09-25 16:55:04 +01:00
Michael Meeks cce3767ba8 First cut SIMD wrappers / separation to accelerate RLE code.
Split it out as a C file, to avoid accidental C++ header inclusion,
and C is a cross-platform assembler anyway so a good match.

Change-Id: I6c042781713aecaf143b9663af8377659a7deaf1
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-09-25 16:55:04 +01:00
Ashod Nakashian 347b3c90e5 wsd: correct assertion
Change-Id: I07d6ec53c08a5f4d7d259224452db4d533e14689
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Michael Meeks 6c382f5415 rle: optimize inner loop bit-bashing.
Simplified code:

+ re-use the bit mask as an inner loop counter.
+ turn alpha only rows into zero length with agreed lastPix.
+ keep lastPix around on the stack.
+ handle odd widths in a duplicate slow-path

Change-Id: Ibc7630f7187ea5f4904c6fed14dda28cdfbf7523

rle: further optimize the pixel reading & de-compression.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ifcaaa45d1de6532b3fd43015c47a37daf56c2ea5
2023-07-31 21:31:13 +01:00
Michael Meeks b700ea08a8 deltas: further increase Kit delta cache to 96 tiles.
Should help for single user with large screens.
Also dump delta cache sizes on USR1.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Id16a287be6b05cee5681abe1d9d2dc0ec61cda2a
2023-07-18 09:43:34 +02:00
Michael Meeks 4d9070b1da Remove long obsolete ENABLE_DELTAS conditional.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I7f254328ba1be8074d8f1feabd7b89304166281d
2023-07-17 11:35:25 +02:00
Michael Meeks d309d7199a deltas: fold the update: command back into an empty delta: command.
Also: address parts of #6897, primarily:

* remove the problematic aspect of bumping the last wid in our
  TileData, when this could trigger a re-send of a previously
  sent delta, causing tile corruption.
    * instead append an empty wid entry.
    * as an optimization - if the last entry is empty update
      the wid - since re-sending an empty delta is of no
      concern.

* simplify a number of code-paths that special-case zero length
  deltas. All deltas now commence with 'D'.

* still track updates in the JS - by detecting empty deltas.

* shares more code and simplifies various paths.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I02af6d4b152524c201b6985b7a3497da7f08a517
2023-07-17 11:35:25 +02:00
Caolán McNamara da10eb9996 return failure early in case of oversized tiles
it shouldn't happen, but return early if it does

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I1733d346ff370827fd882caacebca111f790bbe1
2023-07-06 14:25:31 +01:00
Caolán McNamara 7833e8ce02 asan error seen in testRleComplex
=============== START DeltaTests::testRleComplex
../kit/Delta.hpp:98:23: runtime error: index 4 out of bounds for type 'const uint64_t[4]' (aka 'const unsigned long[4]')
    #0 0x55d29dacd21b in DeltaGenerator::DeltaBitmapRow::PixIterator::next() libreoffice/online-san/test/../kit/Delta.hpp:98:23
    #1 0x55d29da8d514 in DeltaTests::testRleComplex() libreoffice/online-san/test/DeltaTests.cpp:316:16
    #2 0x55d29daf7a87 in void std::__invoke_impl<void, void (DeltaTests::*&)(), DeltaTests*&>(std::__invoke_memfun_deref, void (DeltaTests::*&)(), DeltaTests*&) /usr/bin/../lib64/gcc/x86_64-suse-linux/9/../../../../include/c++/9/bits/invoke.h:73:14

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib6e13eaf0fb89ad086a99251d5b8edcdcedd6800
2023-07-06 11:40:48 +01:00
Caolán McNamara 76a5a9baff transport in rgba order
so if core is compiled with a cairo using rgba the pixels can
be sent without need to reorder in server or client

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iaf0410f1eaa605b9ce2716625f6c968bca523ccb
2023-07-05 11:58:54 +01:00
Caolán McNamara 490b0c0d0d drop non-standard width=400 height=400 tile request in unit test
there since:

commit 232499f542
Date:   Thu Apr 21 12:34:30 2016 +0300

and

commit bf66f7a908
Date:   Mon Jun 13 20:31:14 2016 -0400

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I04745be0581a697bbc3b15ba1d8bb94207320a7a
2023-06-23 16:55:25 +01:00
Caolán McNamara 2e64ad700d push unpremultiply to client
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4aef21179a4ace084762f83f5235c7022d670752
2023-06-23 14:20:42 +01:00
Caolán McNamara 962ecba493 push bgra->rgba conversion to the client
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I425655bfd5e6fd9e1e3ca0b6bcc914511ba188b3
2023-06-23 14:20:42 +01:00
Caolán McNamara 9c780bec82 double delta cache
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4f06f9c4bd6f6fc41b6eed23eb2331daa26f0b5b
2023-06-23 14:07:31 +01:00
Caolán McNamara d3ecb6c95f the tile is assumed to be 256 in width
but as seen with unit-tiletest that is not always the case

==24170==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x63400001e808 at pc 0x558a6f505973 bp 0x7ffc0670e7d0 sp 0x7ffc0670e7c8
READ of size 8 at 0x63400001e808 thread T0 (kitbroker_002)
    #0 0x558a6f505972 in DeltaGenerator::DeltaBitmapRow::initRow(unsigned int const*, unsigned int) Delta.hpp:129:36
    #1 0x558a6f4fc318 in DeltaGenerator::DeltaData::DeltaData(unsigned int, unsigned char*, unsigned long, unsigned long, int, int, TileLocation const&, int, int) Delta.hpp:233:21
    #2 0x558a6f4f8a22 in DeltaGenerator::createDelta(unsigned char*, unsigned long, unsigned long, int, int, int, int, TileLocation const&, std::vector<char, std::allocator<char> >&, unsigned int, bool) Delta.hpp:574:17
    #3 0x558a6f4f2a35 in DeltaGenerator::compressOrDelta(unsigned char*, unsigned long, unsigned long, int, int, int, int, TileLocation const&, std::vector<char, std::allocator<char> >&, unsigned int, bool, bool, LibreOfficeKitTileMode) Delta.hpp:669:14
    #4 0x558a6f41f300 in RenderTiles::doRender(std::shared_ptr<lok::Document>, DeltaGenerator&, TileCombined&, ThreadPool&, bool, std::function<void (unsigned char*, int, int, unsigned long, unsigned long, int, int, LibreOfficeKitTileMode)> const&, std::function<void (char const*, unsigned long)> const&, unsigned int, int, bool)::$_0::operator()() const /home/vmiklos/git/libreoffice/online-san/./common/RenderTiles.hpp:304:38

so just use the rle cache for the first 256 pixels

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8d34ea53bd20b69184e100b56017dfc0a904eaab
2023-06-21 21:31:48 +01:00
Caolán McNamara cc809fda24 fix asan build test
../kit/Delta.hpp:96:23: runtime error: index 4 out of bounds for type 'const uint64_t[4]' (aka 'const unsigned long[4]')
    #0 0x558e8e0f800b in DeltaGenerator::DeltaBitmapRow::PixIterator::next() libreoffice/online-san/test/../kit/Delta.hpp:96:23
    #1 0x558e8e0b8304 in DeltaTests::testRleComplex() libreoffice/online-san/test/DeltaTests.cpp:317:16

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I01da1e99b5d224411344659dce8bd2f29e7d74b0
2023-06-21 17:09:24 +02:00
Michael Meeks 28808ebf6a delta: Add unit tests for RLE encoding, and debugging support.
Change-Id: Ie0b62dbad8af2ab6ff95d6279c69de083c2cd888
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks 9d8e84effb deltas: RLE compress pixel runs to save space & time.
Store a bitmap of whether a pixel is identical to the last
pixel in a set of four 64bit members. These double as a
simple CRC. Store the allocated row size too, and use the
stack as a temporary scratch-space to do the building in.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks 74a1047452 deltas: pure re-factor, store pixels in each DeltaBitmapRow.
Un-necessary allocation overhead for now, but more follows.

Change-Id: I1012678daf021cf63d8fc6e52d25d2dec703c4fb
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks 675c41c644 deltas: pure re-factor: extract out diffRowTo.
Change-Id: I908a486c0c67beaee7b41a85a3bde911f9fe141a
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Caolán McNamara 1063fdbcba cid#318963 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I459f70a41e5c1bab2e575c8d9ee699e213f2456e
2023-06-14 10:10:46 +02:00
Paris Oplopoios 21966e1a9c Fix copy command going out of bounds during delta creation
When creating a delta, the copy command could copy from rows that are
bigger than the height of the tile. This would go unnoticed on light
mode because the js side that applied the delta would apply these out of
bounds rows with a white color, but it is noticable in dark mode. Made
it so the copy command stops copying from out of bounds.

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I4d05cb411958d0945933edb5c812de2dfd9c1abd
2023-06-05 08:59:39 +01:00
Paris Oplopoios baaecac852 Add debug option that allows tile dumping
Added a debug option (triggerable using the about debug menu) that
allows you to dump tiles as they come in

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: If5939b816c1e3598e50c2db4971710524f855909
2023-06-05 08:59:39 +01:00
Michael Meeks 7444decf9f trim memory when user is inactive.
Builds on a new LOK API to do the same in the core.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4443cd2ffbb6c7af0726162aec2ba78fc354d901
2023-03-23 11:31:24 +00:00
Ashod Nakashian 9c39ebad1f wsd: string::empty() is clearer than size() == 0
Change-Id: If2e25d344b5718c35cb9ae7b7519010ee88f0f60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-10 07:45:12 -05:00
Michael Meeks 8ebdde2cb8 zstd: tune for speed, and compress deltas.
Small deltas were not compressed at all, now they are.

Change-Id: I0543a488723816b4140b27c5690f657aea26226e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-21 11:53:59 +01:00
Michael Meeks 19dff9f281 zstd: decompress blobs for testing using zstd not inflate.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I8c2ea8b9cc3561485ec93428c1fe95a20be913fb
2022-11-02 12:09:53 +01:00
Michael Meeks abc469466a Clarify delta count updating.
Change-Id: Ie6d507d9aff80b90c97338ce1526a87ae0688394
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-02 12:09:53 +01:00
Michael Meeks b57689a2e8 in-line ZSTD_minCLevel() call as a constant.
Change-Id: Ie0877b4c3cdc3111d3a35f9ed622d8903675b96a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-02 12:09:53 +01:00
Michael Meeks 2def6dc3d5 Switch to zstd image compression.
zstd provides for much faster compression server-side, as well
as better decompression.

zstd allows us to de-compress a keyframe and several deltas in a
single call in JS, so it is necessar to add a terminator to the
delta stream so that we can detect when to flush the buffer we
are working on - so the next delta applies to the correct data.

Change-Id: I0e292e3a697b4902d6488b7c04deaba2d1485e94
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-02 12:09:53 +01:00
Michael Meeks 8ca42a5d5a delta: fix delta cache sizing.
Change-Id: Ia6ed98534f87006ba5ffcffc8b928f16cfc892cd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-07-28 15:22:58 +01:00
Miklos Vajna b5af14b302 TileLocation::hash(): shift when the input size_t already
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: If4b18b96f3188489f1e5a027e08523722a2d85dc
2022-06-30 15:49:17 +01:00
Michael Meeks 91b20f6448 delta: include canonical-view-id into the TileLocation.
This avoids problems with watermarking cross-talking betwene view.

Change-Id: Ifecf098423451bf7de3827dfdf9fdc078a06c5c9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-22 09:16:45 +01:00
Michael Meeks 88f84a6e2d re-factor TileLocation into its own struct.
Change-Id: Iaef52359114c14dbfbca683393ea91d09635be72
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-22 09:16:45 +01:00
Michael Meeks 04a8462043 deltas: debug dump the state.
Change-Id: Id35f68a108c151de5d2c27800510d17de60faa4c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-16 10:48:55 +01:00
Michael Meeks bef4b1ec5a delta: have own delta cache mutex, and size cache for session count.
Change-Id: I1f970a5f9045df11444f6fec8ce7e8eeb0a71bf5
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-16 10:48:55 +01:00
Michael Meeks 935715309a deltas: switch cache to unordered_set and manage size & lifecycle.
We should have a larger delta-cache with more users eg.

Change-Id: Idc3075636df2e7705950fcf6762e40546792a285
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-16 10:48:55 +01:00
Michael Meeks 4478d2b083 Delta: add checks for bad memory usage across threads.
Change-Id: I09f5ad5b0af44399f92ccc0b62056172f1a0b220
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-06-10 10:10:05 +01:00
Michael Meeks 3e32d3d4d2 perf: better identical run copying while un-pre-multiplying.
Change-Id: I8958e9a072026e8c06c820dc1ab74b44bf12d87b
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-31 19:06:28 +01:00
Michael Meeks ec6431b088 deltas: 64bit copy & CRC for twice the construction speed.
Change-Id: I568abed80c1e571e7a65370b7b4b1049f52ab0b4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-31 19:06:28 +01:00
Michael Meeks 647d2fd708 deltas: allocate a single chunk of pixels, instead of lots of rows.
Avoid std::vector and its peculiarities, also store the crc so
that we get the perf. win from it.

Change-Id: If39ab01b5b987d707d1712076ae9a5beb32b36c2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-31 19:06:28 +01:00
Michael Meeks f2df5d5ff0 deltas: re-factor deltaToDataDelta into DeltaData constructor.
cleanup accessor too.

Change-Id: I7db28780cc3394bc74f9967a1e2c2bbe0e01089c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-31 19:06:28 +01:00
Michael Meeks e71e78a479 perf: deflate optimize for speed not size for full tiles.
We have many fewer full tiles to compress - so we can
trade a bit of space for some speed. Really should use zstd.

Change-Id: I7c310608173c924f175154bf6f7abb43d5e6f08d
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-30 12:32:14 +01:00
Michael Meeks 6483e1500a Enable deltas by default.
Cleanup some debugging, distinguish wsd/viewport delta fetches from
client-side tilecombines.

Update tests for deltas where they are expected.

Change-Id: I3dca09e4ceb094abf03db2aed2618f19351f3e28
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-25 20:31:06 +01:00
Michael Meeks c130231379 deltas: track, transmit and cache deltas (disabled for now)
Squashed from feature/deltas-expanded.

TileCache changes:
    + add montonic sequence (wid) numbers to TileData
    + account for sizes of TileData with multiple blobs
    + simplify saving and notifying of tiles

Sends updates (via appendChanges) based on the sequence the
right mix of keyframes and/or deltas required as a single
message, and parse and apply those on the JS side.

We continue to use PNG for slide previews and dialogs,
but remove PngCache - used by document tiles only.

Annotates delta: properly as a binary package for the websocket.

Distinguishes between deltas and keyframes we get from
the Kit based on an initial un-compressed prefix
character which we then discard.

kit can be forced to render a keyframe by oldWid=0

Track invalidity on tiles themselves - to keep the keyframe around.

    We need to be able to track that a tile is invalid, and so subscribe
    to the updated version as/when it is ready - but we also want to
    store the keyframe underneath any deltas.

force rendering of a keyframe for an empty slot in the TileCache.

force tile sequence to be zero for combinedtiles - so the client can
always request standalone tiles with explicit combinedtiles, or tile
requests.

move Blob to Common.hpp

use zero size for un-changed tiles.

remove obsolete render-id, and color deltas in debug mode.

cleanup unit tests for non-png tile results.

Change-Id: I987f84ac4e58004758a243c233b19a6f0d60f8c2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-24 22:16:58 +01:00