CollaboraOnline / online

Collabora Online is a collaborative online office suite based on LibreOffice technology. This is also the source for the Collabora Office apps for iOS and Android.
https://collaboraonline.com
Other
1.77k stars 679 forks source link

wasteful commandvalues CharFontNAme #3235

Open mmeeks opened 3 years ago

mmeeks commented 3 years ago

This is an Easy Hack. Potential mentors: @gokaysatir

Detailed description and rationale

A kit process sends a message with commandvalues - but it pretty-prints the JSON involved which wastes lots of space and time:

1208559 write(17, "\201\177\0\0\0\0\0\2W\236client-036 commandvalues: {\n \"commandName\": \".uno:CharFontName\",\n \"commandValues\": {\n \"Albany AMT\": [\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"10\",\n \"10.5\",\n \"11\",\n \"12\",\n \"13\",\n \"14\",\n \"15\",\n \"16\",\n \"18\",\n \"20\",\n \"22\",\n \"24\",\n \"26\",\n \"28\",\n \"32\",\n \"36\",\n \"40\",\n \"44\",\n \"48\",\n \"54\",\n \"60\",\n \"66\",\n \"72\",\n \"80\",\n \"88\",\n \"96\"\n ],\n \"Amiri\": [\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"10\",\n \"10.5\",\n \"11\",\n \"12\",\n \"13\",\n \"14\",\n \"15\",\n \"16\",\n \"18\",\n \"20\",\n \"22\",\n \"24\",\n \"26\",\n \"28\",\n \"32\",\n \"36\",\n \"40\",\n \"44\",\n \"48\",\n \"54\",\n \"60\",\n \"66\",\n \"72\",\n \"80\",\n \"88\",\n \"96\"\n ],\n \"Amiri Quran\": [\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"10\",\n \"10.5\",\n \"11\",\n \"12\",\n \"13\",\n \"14\",\n \"15\",\n \"16\",\n \"18\",\n \"20\",\n \"22\",\n \"24\",\n \"26\",\n \"28\",\n \"32\",\n \"36\",\n \"40\",\n \"44\",\n \"48\",\n \"54\",\n \"60\",\n \"66\",\n \"72\",\n \"80\",\n \"88\",\n \"96\"\n ],\n \"Amiri Quran Colored\": [\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"10\",\n \"10.5\",\n \"11\",\n \"12\",\n \"13\",\n \"14\",\n \"15\",\n \"16\",\n \"18\",\n \"20\",\n \"22\",\n \"24\",\n \"26\",\n \"28\",\n \"32\",\n \"36\",\n \"40\",\n \"44\",\n \"48\",\n \"54\",\n \"60\",\n \"66\",\n \"72\",\n \"80\",\n \"88\",\n \"96\"\n ],\n \"Andale Mono\": [\n \"6\",\n ...

This could be caused by:

wsd/ClientSession.cpp- else if (tokens[0] == "commandvalues:") wsd/ClientSession.cpp- { wsd/ClientSession.cpp- const std::string stringMsg(buffer, length); wsd/ClientSession.cpp- const std::size_t index = stringMsg.find_first_of('{'); wsd/ClientSession.cpp- if (index != std::string::npos) wsd/ClientSession.cpp- { wsd/ClientSession.cpp- const std::string stringJSON = stringMsg.substr(index); wsd/ClientSession.cpp- Poco::JSON::Parser parser; wsd/ClientSession.cpp- const Poco::Dynamic::Var result = parser.parse(stringJSON); wsd/ClientSession.cpp- const auto& object = result.extract(); wsd/ClientSession.cpp- const std::string commandName = object->has("commandName") ? object->get("commandName").toString() : ""; wsd/ClientSession.cpp: if (commandName == ".uno:CharFontName" || wsd/ClientSession.cpp- commandName == ".uno:StyleApply") wsd/ClientSession.cpp- { wsd/ClientSession.cpp- // other commands should not be cached wsd/ClientSession.cpp- docBroker->tileCache().saveTextStream(TileCache::StreamType::CmdValues, stringMsg, commandName); wsd/ClientSession.cpp- } wsd/ClientSession.cpp- }

But is most likely caused by the core code being unhelpful:

svx/source/tbxctrls/tbcontrl.cxx: rJsonWriter.put("command", ".uno:CharFontName");

Same thing happens for StyleValues.

We shouldn't be having ' ' or '\n' in there at all.

Thanks ! =)

Code pointers

...

Links to related documentation

...

Additional notes, tips & tricks

...

callmetushar123 commented 1 year ago

@mmeeks Hey I am pretty new, can you tell me how to proceed?

pedropintosilva commented 1 year ago

Hi @callmetushar123 I think @mmeeks laid out sufficient code pointers. But let me link here that file and the respective line from core (distro/collabora/co-22.05 branch) : https://git.libreoffice.org/core/+/refs/heads/distro/collabora/co-22.05/svx/source/tbxctrls/tbcontrl.cxx#1759

codewithvk commented 1 year ago

Hello @mmeeks @pedropintosilva , I would like to take this issue. Do we have any guideline/steps to install libre core on gitpod?

pedropintosilva commented 1 year ago

@codewithvk I'm not sure I follow. Do you mean LibreOffice core? And by GitLab you mean GitHub?

To build LO locally please follow "Option A" https://collaboraonline.github.io/post/build-code/#build-code-n-lo

codewithvk commented 1 year ago

@pedropintosilva Apologies for the unclear information. In reality, I was seeking a way to install the LibreOffice core on Gitpod, as I was unable to find any guidelines on how to do so.

pedropintosilva commented 1 year ago

@codewithvk at the moment it's not possible, we use the pre-build core archive in the gitpod setup.

codewithvk commented 8 months ago

@pedropintosilva, can you please confirm whether it has already been resolved? Or am I taking the wrong steps?

I'm receiving the following sample JSON in the buffer. 0x55b845299e70 "{ \"jsontype\": \"notebookbar\", \"action\": \"update\", \"id\": 0, \"control\": { \"id\": \"fontnamecombobox\", \"type\": \"combobox\", \"text\": \"Liberation Sans\", \"enabled\": false, \"children\": [ { \"id\": \"\", \"type\": It seems to be perfect.

eszkadev commented 8 months ago

@codewithvk that one is an update for the font selector widget and it is fine already. But the original description is probably about message which is sent on the initial loading of the document. It sends all the fonts list. commandvalues: {\n "commandName": ".uno:CharFontName" Maybe in the /tmp/coolwsd.log it is still visible?