Commit graph

115 commits

Author SHA1 Message Date
Ashod Nakashian
ad70138fc9 loolwsd: move file utilities into FileUtil files
Change-Id: Ib0c0bc66adabe6885f7ac16414a3d5af13d72893
Reviewed-on: https://gerrit.libreoffice.org/30820
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:23:01 +00:00
Ashod Nakashian
c8eb2ba612 loolwsd: cleanup tile response handling
Change-Id: I34b76b463c05e3479d1fd1516906c9a75282c753
Reviewed-on: https://gerrit.libreoffice.org/30419
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-31 06:08:01 +00:00
Ashod Nakashian
a2ef70c71c loolwsd: mark all tiles but the first to have come from the cache
While this has some overhead, it makes debugging of tile
rendering easier.

Change-Id: I0430015f41fd044e4be1099a5d61a23c0ef88176
Reviewed-on: https://gerrit.libreoffice.org/30245
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-25 01:01:27 +00:00
Ashod Nakashian
cdf6beee86 loolwsd: lookupRendering -> lookupCachedFile
Change-Id: I668e1e11aaf9a88b40084ac23bcd574cf258262f
Reviewed-on: https://gerrit.libreoffice.org/30244
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-25 00:57:39 +00:00
Ashod Nakashian
693d6ccdbf bccu#2104 - writer: undo/redo doesn't invalidate properly
Change-Id: I9b3ee76cfde2c15ae59bb393070224c9f14ab586
Reviewed-on: https://gerrit.libreoffice.org/30109
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-20 15:14:21 +00:00
Tor Lillqvist
97adaf935b Don't let 'canceltiles' messages affect slide thumbnails being rendered
Document that the 'id' parameter of a 'tile' message is not (should
not be) used for anything except slide thumbnails.

If we later need some more generic way to distinguish the purpose of
tile requests, need to come up with something else, like a 'purpose'
parameter.
2016-10-04 13:31:36 +03:00
Ashod Nakashian
2907d802a5 loolwsd: cleanup and logs
Change-Id: I46eafb970ca144e7eb0837c80d790433cf1e151a
Reviewed-on: https://gerrit.libreoffice.org/29466
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-03 05:31:26 +00:00
Tor Lillqvist
96e6ad7502 Re-think disk full handling
Instead of trying to inform the sysadmin (which we did not yet try to
do in any meaningful way), inform all connected clients (even those
editing other documents).

We use 'error: cmd=internal kind=diskfull' as the message to the
clients. The loleaflet code needs to be updated to handle that
carefully by displaying a very prominent message that tells the user
that all bets are off.

Also add a unit test for the functionality.

Document the new protocol details.

The code for this alert functionalty became a bit less elegant than I
like because of the way we include Util.cpp in the unit test 'test'
program.

Still need to add code to check for disk full in more places, not just
when saving a cached tile or font. Probably we should even actually
check for disk space on the file system(s) we use getting alarmingly
low, not just check for file writing operations that fail. Later.
2016-09-29 00:23:14 +03:00
Miklos Vajna
31867f669d Fix remaining uninitialized members
The missing init of mutexes is probably theoretical, the TraceFile and
the Unit ones were real errors, I think.

Change-Id: If19c23a9c93d34059998346af8d45c26a34043a6
2016-09-28 10:20:48 +02:00
Tor Lillqvist
891b942e7c Handle disk full situations more gracefully
Introduce new API in our Util namespace to save data to a file
safely. The data is written to a temporary file in the same directory
and after that has succeeded, it is renamed atomicaly to the intended
name. If any step of the saving fails, neither the temporay file or
the intended target (if one exists before) is left behind.

Also add an API intended to alert the sysadmin in cases where their
attention and action are required. This is not yet properly
implemented. See FIXME comment for discussion.
2016-09-27 15:53:48 +03:00
Ashod Nakashian
e9a7f8c6c6 loolwsd: split tilecombined in the TileQueue
Delaying the splitting maximizes the chances
that we will deduplicate and combine them
in the queue optimally.

Change-Id: Ib721fe7596de7ad5d34159949fe75f16e861eb24
Reviewed-on: https://gerrit.libreoffice.org/29287
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-26 02:50:17 +00:00
Ashod Nakashian
f6a9de1b2d Revert "loolwsd: TileCache is told to save or not before...
This reverts commit 01718c5c68.

Change-Id: I6fa49f8d1f5c6ba7bdcd8cfa0866e0e15380607d
Reviewed-on: https://gerrit.libreoffice.org/29281
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-26 02:38:29 +00:00
Ashod Nakashian
1f207290f0 loolwsd: don't assert if we can't find subscribers to forget
Change-Id: Ic860eb58f17d1d7c8341881be2991d0bd8712a14
Reviewed-on: https://gerrit.libreoffice.org/29208
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-23 02:14:10 +00:00
Ashod Nakashian
01718c5c68 loolwsd: TileCache is told to save or not before notifying subscribers
Change-Id: Ibe24bbe9b4bf6fbaae7c9fcea5f919f7091d299e
Reviewed-on: https://gerrit.libreoffice.org/29207
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-23 02:13:48 +00:00
Ashod Nakashian
a04f75d515 loolwsd: no need to return anything when subscribing to TileCache
Change-Id: I7b8280bf150a74db243c17cea11afc40899c4c0d
Reviewed-on: https://gerrit.libreoffice.org/29165
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:36:02 +00:00
Ashod Nakashian
d1a5745519 loolwsd: TileBeingRendered now holds the original TileDesc
Change-Id: I1c56e6b87703285ce55818aefd51ded3fefa3b74
Reviewed-on: https://gerrit.libreoffice.org/29164
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:35:17 +00:00
Ashod Nakashian
b72c777f85 loolwsd: const members where possible
Change-Id: I318a76ad9e0c0ca334eb9239b61e674ce9a6a596
Reviewed-on: https://gerrit.libreoffice.org/29162
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:34:03 +00:00
Ashod Nakashian
1641f756b2 loolwsd: improved logging
Change-Id: I1a1559754efcb0614875dc76ae0637ed6dc1ba77
Reviewed-on: https://gerrit.libreoffice.org/29160
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-22 03:32:48 +00:00
Tor Lillqvist
299a573996 Fix heap-use-after-free detectec by Clang's AddressSanitizer 2016-09-21 17:38:23 +03:00
Ashod Nakashian
ae4a9f7110 loolwsd: always request newer tile version
And accept any version newer than expected.

Since we have proper de-duplication of tiles
requesting newer versions reduces changes of
races between client and the renderer.

Change-Id: I30bb53f98ef6f1461b53c1cf527d315dc35f7f26
Reviewed-on: https://gerrit.libreoffice.org/29125
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:18:09 +00:00
Ashod Nakashian
87a9f6e166 loolwsd: don't remove subscriptions on invalidation
Tile invalidation is a hint to the clients to request
fresh tiles and replace the existing ones. However
any outstanding tile request will be rendered anew.
So no need to remove those.

Nonetheless, we should issue new versions to avoid
race between old tile and invalidate. This can
happen when a tile rendered just before invalidate
reaches the client after the invalidate. The client
will think the tile is a new one when it was rendered
just before the invalidate.

Change-Id: Ieb2ffab1214dd904da8e532e7d9d20e6ad783b78
Reviewed-on: https://gerrit.libreoffice.org/29123
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:16:57 +00:00
Ashod Nakashian
9e5df31cbb loolwsd: make sure to combine all contiguous tiles
Change-Id: If65e2ff53f593015ba7df23b6943a711c36550de
Reviewed-on: https://gerrit.libreoffice.org/29119
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:14:41 +00:00
Ashod Nakashian
6bf643183e loolwsd: cancel subscriber tiles only
Change-Id: I207f2332520f29308a2994769aa3a12ea5178477
Reviewed-on: https://gerrit.libreoffice.org/29118
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:14:03 +00:00
Ashod Nakashian
8f213bc170 loolwsd: canceltiles re-designed using tilecache instead of queue
Reviewed-on: https://gerrit.libreoffice.org/28526
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 571ff06906)

Change-Id: Ie8f2c87a705aac14dd6f139c384f000df98db909
Reviewed-on: https://gerrit.libreoffice.org/29117
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-21 05:13:18 +00:00
Ashod Nakashian
faf6cf7ce4 loolwsd: better logging in subscribeToTileRendering
Change-Id: I5b94cda02e4f0e1154de81fc7bb4380332f2eeeb
Reviewed-on: https://gerrit.libreoffice.org/29070
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:34:59 +00:00
Ashod Nakashian
ec4b489885 loolwsd: remove unused priority flag from saveTileAndNotify
Change-Id: I49309bb80a6b9e9e8265da8f8db966b98e362f0a
Reviewed-on: https://gerrit.libreoffice.org/29068
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:32:48 +00:00
Ashod Nakashian
e7272019dc loolwsd: remove tile queue and simplify tile response
Tile queue was used to process canceltiles commands.
Since those are handled by TileCache, there is no need
for queues and the threads that pump them.

But because these queues were also used to buffer between
WSD internals and clients, such that a slow client wouldn't
block WSD while sending back tiles, it is necessary
to reword that logic.
In subsequent commits that will change as well.

With this change not only do we save a thread per client,
but we also reduce latency of tile, and improve typing
responsiveness, by almost 3x or more! Latencies are
down to ~15ms from almost 50ms.

Reviewed-on: https://gerrit.libreoffice.org/28575
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 59eaacd2f8)

Change-Id: I77813267a95a724491165792ec020ae00953c05e
Reviewed-on: https://gerrit.libreoffice.org/29066
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-20 03:30:43 +00:00
Ashod Nakashian
ffa146a870 loolwsd: log tile version in stats
Change-Id: Ia8a466b50f5236cb555c962830843c4d7d77fa97
Reviewed-on: https://gerrit.libreoffice.org/28956
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-16 12:32:22 +00:00
Michael Meeks
6bce292c44 Send intermediate tiles back even when we they are older.
Should improve interactivity and avoid jerky feedback.
2016-09-01 21:18:38 +01:00
Ashod Nakashian
16605b9289 Revert "loolwsd: canceltiles re-designed using tilecache instead of queue"
This reverts commit 571ff06906.

Change-Id: Icf9caeafc640b815f64211f240cfdac8e91694a1
Reviewed-on: https://gerrit.libreoffice.org/28595
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:47 +00:00
Ashod Nakashian
77a693c353 Revert "loolwsd: remove tile queue and simplify tile response"
This reverts commit 59eaacd2f8.

Change-Id: Ieba9bbaaa6406e3e685b46ce12a44a0766127815
Reviewed-on: https://gerrit.libreoffice.org/28594
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 12:37:38 +00:00
Ashod Nakashian
59eaacd2f8 loolwsd: remove tile queue and simplify tile response
Tile queue was used to process canceltiles commands.
Since those are handled by TileCache, there is no need
for queues and the threads that pump them.

But because these queues were also used to buffer between
WSD internals and clients, such that a slow client wouldn't
block WSD while sending back tiles, it is necessary
to reword that logic.
In subsequent commits that will change as well.

With this change not only do we save a thread per client,
but we also reduce latency of tile, and improve typing
responsiveness, by almost 3x or more! Latencies are
down to ~15ms from almost 50ms.

Change-Id: I9bb5856efed28caea9d4e6f94f77b093779e5241
Reviewed-on: https://gerrit.libreoffice.org/28575
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-01 03:59:31 +00:00
Ashod Nakashian
571ff06906 loolwsd: canceltiles re-designed using tilecache instead of queue
Change-Id: I4b9ba91ee08bc9dd8d27df275e303f5517d9740c
Reviewed-on: https://gerrit.libreoffice.org/28526
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 04:44:56 +00:00
Ashod Nakashian
3af0d69d22 loolwsd: isTileBeingRenderedIfSoSubscribe -> subscribeToTileRendering
Simpler yet descriptive function name and better logging.

Change-Id: Ic903197d5772b7994ffa8136cfae771deee3a24a
Reviewed-on: https://gerrit.libreoffice.org/28291
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 04:54:29 +00:00
Ashod Nakashian
08909b2a3d loolwsd: doxygen comments added to all classes
Change-Id: Ia485c2dcec20a6840d46836a61f75a8e7e8762ed
Reviewed-on: https://gerrit.libreoffice.org/28128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-15 03:12:31 +00:00
Pranav Kant
d18379adce loolwsd: Show only abbreviated message when reading from cache
Change-Id: I6d5c8984010e2917b9069df6ee3b0a28c678b297
2016-07-11 11:24:19 +05:30
Pranav Kant
0b8e9dedaf loolwsd: Print abbreviated message while saving to TileCache
Change-Id: I1f77062466e3672ce742b6a46e3c39b35ce70f31
2016-07-01 20:29:19 +05:30
Ashod Nakashian
9dbc213337 loolwsd: log tile rendering rountrip time
Change-Id: Ib97e196d6de053e6b79ea448296003f30a5949b5
Reviewed-on: https://gerrit.libreoffice.org/25347
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:58:25 +00:00
Ashod Nakashian
157386e3bc loolwsd: process tiles under the cursor with priority
Change-Id: I7993ee049c5c0835cae588ff54163f135c4f8b02
Reviewed-on: https://gerrit.libreoffice.org/25345
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:57:16 +00:00
Ashod Nakashian
6e54fd05f9 loolwsd: merge saveTile and notifyAndRemoveSubscribers
Change-Id: I8282604c02a9fd1a7a1e2a5df29e2f84fca151a6
Reviewed-on: https://gerrit.libreoffice.org/25344
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:54:55 +00:00
Ashod Nakashian
e5aaac7631 loolwsd: Tile versioning and fix to race conditions
Tile invalidation and painting can race with one another.

A race when the user types two characters in quick succession:
1. After the first key press, the tile is invalidated.
2. The client request the tile on receiving the invalidate.
3. TileCache doesn't find it, and adds subscription.
 A. Sometime before rendering, the second key press is received.
 B. This invalidates the very same tile.
 C. The client request the same tile.
 D. TileCache finds a subscription and ignores the new one.
4. The tile is rendered and sent back.
5. Subscription is found and the tile is forwarded to clients.
6. Subcription is removed as the request is fullfilled.
 E. The second tile is rendered and sent back.
 F. TileCache finds no subscription and the tile is dropped.

End result: Only the first character appears on the screen.

Versioning fixes the above situation by making sure that in
step 5 the subscription will show to belong to a different
(and newer version) and so the tile will be ignored.
Instead, at F the TileCache will find both subscription
and a matching version and the lastest version will always
be sent back to the client.

Change-Id: I7d7fe1407cda1908d794683c3ce4c2fd18609a2f
Reviewed-on: https://gerrit.libreoffice.org/25341
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-23 01:52:36 +00:00
Ashod Nakashian
fae850189d loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.

Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.

This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.

Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).

Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:52:54 +00:00
Ashod Nakashian
b2fa9d6f2e loolwsd: moved TileDesc into own file
Change-Id: I54162f7ebaaca51f9c52a30af1e278db212562fa
Reviewed-on: https://gerrit.libreoffice.org/25261
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 15:49:10 +00:00
Ashod Nakashian
b2881306f1 loolwsd: MasterProcessSession splitting: moved input queue
Change-Id: Id1c2b0f76a96ca48905d354c02a96b35ba29fadc
Reviewed-on: https://gerrit.libreoffice.org/25046
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:21:44 +00:00
Ashod Nakashian
d18bca992c loolwsd: use TileDesc instead of explicit values
Change-Id: I56ba6c4e63a495500093e7353477175d40152d11
Reviewed-on: https://gerrit.libreoffice.org/25020
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 23:00:43 +00:00
Ashod Nakashian
2b0347e391 loolwsd: new tile descriptor class to represent tiles
Change-Id: I680ea2d698a352bf3f99b37713d68c34d9502ea4
Reviewed-on: https://gerrit.libreoffice.org/25019
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 22:56:48 +00:00
Ashod Nakashian
57947dfd4d loolwsd: timeout tile requests and reissue them
Change-Id: I7dee06d905f59d73fdc9aa4e03831c5e5d16b9e3
Reviewed-on: https://gerrit.libreoffice.org/25007
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-15 14:33:47 +00:00
Miklos Vajna
c2fc95ac23 Drop unused using declarations
Change-Id: Iee778833781c6f00c1fb0b8fc1975acfe4fb0cd9
2016-05-10 09:14:22 +02:00
Ashod Nakashian
1643938a8e loolwsd: support the tile id param when broadcasting tiles to subscribers
Obviously this is dangerous, since the id is not part of the
subscription key (the filename) so different clients could
have different ids on the same part, but in practice I
expect this not to happen. Though that clearly depends on
how clients use the id.

Change-Id: I52a0b043c9b5e5ad1111b692e4216cc9ffec5b2b
Reviewed-on: https://gerrit.libreoffice.org/24680
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 14:23:22 +00:00
Ashod Nakashian
cd8d48e6bb loolwsd: tile logs
Change-Id: Id5c8b688c36038dc6f02ad95ad1c43412dcd2c31
Reviewed-on: https://gerrit.libreoffice.org/24668
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-05 02:34:13 +00:00