- we cannot get rid of UnitBase::get() which returns the last
set Unit class because we use it for example in WebSocketHandler
where we don't know which kind of test we run
- free memory correctly and reset global variables for subclasses
- setup _type member variable on construction
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ic61b88785bff7de63b11ce2046eecc993c3ddeaf
On android we had issue with not working release builds
(worked when optimization flag -O0 was used for Unit.cpp).
Global which stored instance of UnitBase subtype was returned
after cast to a choosen subtype. Unfortunately in case when
android didn't work UnitWSD was returned in UnitKit::get() !
Thich patch makes us sure we don't cast to not-correct type.
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I98e91d8fa82a8e81a8f7cee2fe3109b67c4f64f7
Hopefully helps to hunt segv's more effectively in development.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ife800f9902fe8d95711b3b14867ee21bb3c3f21b
We don't want leaking tiles to take up valuable space on the device.
Not even just while a document is open.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I761c2bb2ab121ee76b5535e96bd5702d0fce6856
Fix silly mistake in my previous commit. Had put code in #if 0 that
should be in #ifdef IOS.
Change-Id: I72f4dc3867bd070a01a4ba5625baba0eea3c2d73
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Normally (ideally), tiles (.bmp files) are removed as soon as the JS
has displayed them. But occasionally something goes wrong and they are
left behind. (For instance, it seems to happen if the user closes the
document immediately when it shows up.)
Do not leave them on disk until the app starts the next time.
Change-Id: I0c764280a69a16ad3b7b67c329832fd5331c2e1e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
The worker threads can be running and have not yet responded
to the last _cond.wait() by the time we start compressing again
- at least under valgrind:
loolforkit-nocaps: ./common/RenderTiles.hpp:304: void ThreadPool::run(): Assertion `_working == 0' failed.
==240379== Process terminating with default action of signal 6 (SIGABRT): dumping core
==240379== at 0x5505322: raise (raise.c:50)
==240379== by 0x54EE863: abort (abort.c:79)
==240379== by 0x54EE748: __assert_fail_base.cold (assert.c:92)
==240379== by 0x54FD9D5: __assert_fail (assert.c:101)
==240379== by 0x5886BB: ThreadPool::run() (RenderTiles.hpp:304)
==240379== by 0x56DC02: RenderTiles::doRender(std::shared_ptr<lok::Document>, TileCombined&, PngCache&, 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&) (RenderTiles.hpp:711)
==240379== by 0x5A0104: Document::renderTiles(TileCombined&, bool) (Kit.cpp:762)
==240379== by 0x59CF1A: Document::renderCombinedTiles(StringVector const&) (Kit.cpp:719)
==240379== by 0x59AEC8: Document::drainQueue(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&) (Kit.cpp:1570)
That means our queue starts processing work as we do the unlocked
queue push - causing some potential badness.
Change-Id: Ib0578dac009376c0676da73a8c1d8960304dc072
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Why pass a dozen empty arguments each time: someone bitten
again by the default vector constructor.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I31bc6f23f0b5d7352b85d3df4b7b5298199044a1
_firstLine must be assigned before _data is
changed, as it is used to check _data's
first line hasn't changed
Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: I79dfd0a64d53fc8503709015bbe7ab6875a58204
And make return const to prevent _firstLine being
mutable.
Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: I1a6e391cd128704b67ec5cc99a4ed4d105f64e29
_firstLine is no assigned when firstLine() is called
and _firstLine is empty.
Signed-off-by: NickWingate <nicholas.wingate03@gmail.com>
Change-Id: Ie6d86abd1f9db7a4f05e95e41f6b791f5923729f
Remove the app's copy of the document after core has saved it and we
have stored the edited version at its real location.
Remove possible leftover tile bitmaps when the app starts.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ibc41be38c2cfb689c532640d148116bc06a248ab
This can happen on an assertion failure, and causes noise while looking
for real memory errors.
Also disable an unstable test, it's not clear that it passes depending
on how loaded the machine is (just increasing timeouts doesn't seem to
help).
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I049bd0a06f41e2d43702ec12a2c35944bc5200d8
When adding a freshly arrived textinput message to the queue, check if
there is an outstanding one queued, and if so, remove it, and prefix
its text to the text in the fresh message. Don't do this if there are
messages inbetween that affect what the textinput messages do
semantically, including textinput messages from other clients.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I712eebfb10d410bb424157c8df46b2848a236d88
Records the uno commands from different instances of ChildSession and
dumps the last 4 uno commands into the crashlog during a fatal crash
Signed-off-by: Gopi Krishna Menon <krishnagopi487.github@outlook.com>
Change-Id: I838f71769dc08df7076c040f3d72c15f7607e9d3
Makes unit-rendering-options fail reliably.
This reverts commit 175c9c5b2a.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id05c911991baaae0dbc52678a192fc01639352e0
By passing a traceevent=yes query parameter in the URL. Note that if
Trace Event generation is not enabled in loolwsd.xml this will have no
effect.
It is a bit silly to notice this query parameter only in loleaflet and
then send the information back to the server. Would be better if the
server noticed it itself before sending the URL to loleaflet.
While at it, let's not bother ever enabling Trace Event generation in
the WSD process. That is not what we are interested in.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I985bfd1e2dbd14aa5a55b386b4762fb64bcb4008
Write to the Trace Event JSON file in just one place, protected by a
mutex.
Handle metadata events separately. We want them to propagate to the
output if Event Trace generation is just enabled, regardless whether
it has been turned on or not.
We can send the metadata for the Kit process only after we have opened
the docuemnt as sending a Trace Event to WSD uses the (singleton)
Document object in Kit.
Introduce some new functions for the above and adapt callers
appropriately.
Generate a Complete event for the handling of one image tile, from
setting the src attribute of the Image object to finishing the onload
function.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5978e0fb2495e0d2dc479bf861eb4ac7da03fa50
We automatically emit metadata events that identify threads.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Icb25b5cfc29b28ba7112ca72de56dbb697c8dd5a
Move the generic dummy implementation of
TraceEvent::emitOneRecording() to a source file of its own. (That is
the one which is used in test and tool executables.)
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I81cab07e5a6852b42d278a5446c13c3825cf546e
To avoid writing (saving) while reading (uploading) or
any other undesirable racse on the document file,
we atomically rename the file after saving on disk
to pass ownership.
After saving in Core, we rename the document in the
jail to .upload (by appending it). DocumentBroker
looks for the file with that extension and atomically
renames it to .uploading (by appening the 'ing' suffix).
This way, the Kit only renames from the original to
.upload and DocBroker renames only .upload to .uploading.
This guarantees that we never rename the same file
concurrently.
Uploading decision is strictly based on the modified
timestamp of the .uploading file, compared to the
timestamp of the last file we uploaded successfully.
Change-Id: I03520cd8c87605f6dad417e7a978204f76fc0c38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Using for fuzzing and integration testing.
With unit-tests.
Change-Id: I23f8c619e239310d92c74c4d5e4157afb52a5e56
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
It was a request an approved by @kendy despite the signal
handler limitations. After several tries, we were blind
when we introduce the commit using the heap.
This reverts commit 9720eb0f81.
Make sure to avoid most of the code path through createArgsString() if
Trace Event generation is not turned on.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id86b2c9b4ded9d402647b7a12b9290d0122ba2aa
Modelled on how it is done in core. ProfileZone is derived from
NamedEvent which is derived from TraceEvent. Here we don't keep any
separate ProfileZone.hpp, though.
This was needed to introduce generation of "instant" events here, too.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6583134e96001641c50339deb4197fca6ab7d5d5
Add a way to set it from the client.
For now, in the Help > About dialog, the L key toggges the logging
level between the default (whatever is set in loolwsd.xml or on the
loolwsd command line) and the maximum a client is allowed to set
(which also can be set in loolwsd.xml or on the loolwsd command line).
Also while at it, uncouple the toggling of the Trace Event generation
from the triple-click tha toggles tile debugging. It is now on the T
key.
Also swap the meaning of "min" and "max" for the logging levels. Even
if the Poco::Message::Priority values are such that the less urgent
priorities have a numerbcally higher value, conceptually it is more
clear to say the more urgent priorities (levels) are "higher".
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5383b16ead7d2d378901525eb0d16513d88f045e
The "StaticNameHelper" was more than just related to a "name", so call
it StaticHelper instead. And why call the variable of that type
"Source"?
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I099b326cc731e7fb4c96ead9ec19143257090cb1
I had accidentally used core naming conventions for ProfileZone.
Change-Id: If10eceb7a5a29d26662d5b21a9289681d814a12e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Don't bother collecting them into a vector, like in core. Instead,
just call a static member function ProfileZone::addOneRecording() for
each Event Trace object (string) to be emitted. That function then
needs to be implemented separately in each executable. In WSD it logs
the object to the Event Trace file. In Kit it sends it to WSD for
logging. In Unit tests we use a dummy implementation.
(If Event Trace logging is not enabled at all in loolwsd.xml (the
default), nothing is done, of course.)
When receiving the "traceeventrecording start" or "traceeventrecording
stop" message from the client, turn ProfileZone recoring on or off in
the WSD and Kit process. (Probably in WSD the flag should be
per-client.)
Change-Id: Ie1127d65dd44ed77e7eeab4b0f0a90cce95dc4a2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Note that the C++ ProfileZone class here in Online is totally separate
from the comphelper::ProfileZone in core (which is now derived from
the more generic comphelper::TraceEvent class there).
Also note that this is work in progress and I know that there isn't
any code yet to write out the collected information from this C++
ProfileZone stuff here in Online. Which is why we don't actually have
any ProfileZone variables yet sprinkled through the code. That is
upcoming.
And finally, note that the Trace Event stuff in loleaflet also is
unrelated.
Change-Id: I8765d6dbc1d5108d9d1042781644cbee2419cd9d
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Add `dumpState` methods to `TileQueue`, `PngCache`, `ThreadPool` classes
and call them from Document::dumpState method within kit.Kit.cpp.
Because `dumpState` method of `_websocketHandler` is protected,
currently we can't dump its internals.
Also dump the other members of the `Document` class. Note that as
`_lastMemStatsTime` is never used, we don't dump it. It seems we could
simply delete it.
Signed-off-by: Gökhan Karabulut <gokhanettin@gmail.com>
Change-Id: Ia89b7fff41eaf475c7a09a644c0eb523b72cf97d