# Office engine: @matbee/libreoffice-converter 2.7.2, patch level p2

LibreOffice compiled to WebAssembly. Licence: MPL-2.0 (declared in the package; the source repository has no LICENSE file).

- Package: https://www.npmjs.com/package/@matbee/libreoffice-converter/v/2.7.2
- Source and build scripts: https://github.com/matbeedotcom/libreoffice-document-converter
- Build scripts of this version: https://github.com/matbeedotcom/libreoffice-document-converter/tree/v2.7.2/build (LibreOffice patches in build/patches)
- LibreOffice source: commit d1c9e0e4e1ddeb24fe8f93e56860b3765043f8b1 of https://git.libreoffice.org/core (the build ID in the engine file instdir/program/versionrc)
  - browse: https://github.com/LibreOffice/core/tree/d1c9e0e4e1ddeb24fe8f93e56860b3765043f8b1
- Licences of LibreOffice's third-party libraries and fonts: licenses/libreoffice-24.8-notices.html on this site (readlicense_oo/license/license.xml of that commit)
- Upstream issue of the deadlock: https://github.com/matbeedotcom/libreoffice-document-converter/issues/19

## Patches (exact text replacements)

- `wasm/soffice.js`: LibreOffice main() must not start on its own: it races LibreOfficeKit init and deadlocks (upstream issue #19, fix of open PR #21).
  - before: `while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true`
  - after: `while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=false`
- `wasm/soffice.js`: A pool of 8 pthreads instead of 4 (upstream issue #19, default of open PR #20).
  - before: `initMainThread(){var pthreadPoolSize=4`
  - after: `initMainThread(){var pthreadPoolSize=8`
- `wasm/soffice.js`: Shared memory maximum 2 GiB instead of 4 GiB: iOS Safari reportedly refuses a 4 GiB shared maximum (WebKit bug 255103).
  - before: `wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:65536,shared:true})`
  - after: `wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768,shared:true})`
- `wasm/soffice.js`: The heap growth limit matches the 2 GiB memory maximum, so the engine never tries to grow past it.
  - before: `getHeapMax=()=>4294901760`
  - after: `getHeapMax=()=>2147483648`
- `dist/browser.worker.global.js`: No routine log, info or debug output of the engine worker in the console (warnings and errors stay).
  - before: `(function(){'use strict';`
  - after: `(function(){'use strict';console.log=console.info=console.debug=()=>{};`
- `dist/browser.worker.global.js`: No reuse of the last document by a sampled hash (length plus about 1000 bytes): two different files could match and render the wrong document. Each document now loads from its own bytes.
  - before: `if(v&&v.inputHash===t&&c)return console.log`
  - after: `if(false&&v&&v.inputHash===t&&c)return console.log`
- `dist/browser.worker.global.js`: No LibreOffice debug log in the console (SAL_LOG=+ALL is very verbose and can print document details).
  - before: `a.ENV.SAL_LOG="+ALL"`
  - after: `a.ENV.SAL_LOG="-ALL"`
- `dist/browser.worker.global.js`: No LibreOffice standard output in the console.
  - before: `print:console.log,printErr:console.error}`
  - after: `print:()=>{},printErr:()=>{}}`

## SHA-256

- original `wasm/soffice.js`: b67acadcb30171e6ec018754fcbe5b527443a3ef1c84f352e29aecff6d210e43
- original `wasm/soffice.wasm`: ea3d8f3b69bd1e586a8ea973e0dfa61c758612fcc529dc94ac2e30519f8b4f7b
- original `wasm/soffice.data`: 8f4e98aa67e108e161cecc7906d7ac0dd3941ef9347f999c3b9dbc049f165020
- original `wasm/soffice.worker.js`: 458bc142e7f837baf44a2d186a0b65b0a11ece760e5dab79ebca2789c9feeef5
- original `dist/browser.js`: 5650066a959e9f8c80722830405afbc0879a0ab98a2f2684aeed75ecb80fd6bc
- original `dist/browser.worker.global.js`: 9401aff2213772d7114fe417e3f34eb359905ae3a4e94a735644d926d593e276
- patched `wasm/soffice.js`: 48063db3e6a151b921c0ef48cef612e96659b39a2391fef154154ea6e2489cd0
- patched `dist/browser.worker.global.js`: 0ad4f6bf851c4129388ca1f3b3ec671f322d5a7ea18e2d9bd6939032b3126f21
- `soffice.wasm` (inflated): ea3d8f3b69bd1e586a8ea973e0dfa61c758612fcc529dc94ac2e30519f8b4f7b; 3 gzip parts, hashes in engine.json
- `soffice.data` (inflated): 8f4e98aa67e108e161cecc7906d7ac0dd3941ef9347f999c3b9dbc049f165020; 2 gzip parts, hashes in engine.json
