Skip to content

Commit b4aa375

Browse files
authored
Merge pull request #27650 from element-hq/rav/remove_olm
Remove code which loads legacy libolm
2 parents b4d3430 + 438d07b commit b4aa375

File tree

4 files changed

+5
-71
lines changed

4 files changed

+5
-71
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
"@types/react": "17.0.80"
7272
},
7373
"dependencies": {
74-
"@matrix-org/olm": "3.2.15",
7574
"@matrix-org/react-sdk-module-api": "^2.3.0",
7675
"jsrsasign": "^11.0.0",
7776
"katex": "^0.16.0",

src/vector/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ async function start(): Promise<void> {
110110
rageshakePromise,
111111
setupLogStorage,
112112
preparePlatform,
113-
loadOlm,
114113
loadConfig,
115114
loadLanguage,
116115
loadTheme,
@@ -148,7 +147,6 @@ async function start(): Promise<void> {
148147
}
149148
}
150149

151-
const loadOlmPromise = loadOlm();
152150
// set the platform for react sdk
153151
preparePlatform();
154152
// load config requires the platform to be ready
@@ -215,7 +213,6 @@ async function start(): Promise<void> {
215213
// app load critical path starts here
216214
// assert things started successfully
217215
// ##################################
218-
await loadOlmPromise;
219216
await loadModulesPromise;
220217
await loadThemePromise;
221218
await loadLanguagePromise;

src/vector/init.tsx

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
21-
// @ts-ignore
22-
import olmWasmPath from "@matrix-org/olm/olm.wasm";
23-
import Olm from "@matrix-org/olm";
2420
import * as ReactDOM from "react-dom";
2521
import * as React from "react";
2622
import * as languageHandler from "matrix-react-sdk/src/languageHandler";
@@ -76,48 +72,6 @@ export async function loadConfig(): Promise<void> {
7672
}
7773
}
7874

79-
export function loadOlm(): Promise<void> {
80-
/* Load Olm. We try the WebAssembly version first, and then the legacy,
81-
* asm.js version if that fails. For this reason we need to wait for this
82-
* to finish before continuing to load the rest of the app. In future
83-
* we could somehow pass a promise down to react-sdk and have it wait on
84-
* that so olm can be loading in parallel with the rest of the app.
85-
*
86-
* We also need to tell the Olm js to look for its wasm file at the same
87-
* level as index.html. It really should be in the same place as the js,
88-
* ie. in the bundle directory, but as far as I can tell this is
89-
* completely impossible with webpack. We do, however, use a hashed
90-
* filename to avoid caching issues.
91-
*/
92-
return Olm.init({
93-
locateFile: () => olmWasmPath,
94-
})
95-
.then(() => {
96-
logger.log("Using WebAssembly Olm");
97-
})
98-
.catch((wasmLoadError) => {
99-
logger.log("Failed to load Olm: trying legacy version", wasmLoadError);
100-
return new Promise((resolve, reject) => {
101-
const s = document.createElement("script");
102-
s.src = "olm_legacy.js"; // XXX: This should be cache-busted too
103-
s.onload = resolve;
104-
s.onerror = reject;
105-
document.body.appendChild(s);
106-
})
107-
.then(() => {
108-
// Init window.Olm, ie. the one just loaded by the script tag,
109-
// not 'Olm' which is still the failed wasm version.
110-
return window.Olm.init();
111-
})
112-
.then(() => {
113-
logger.log("Using legacy Olm");
114-
})
115-
.catch((legacyLoadError) => {
116-
logger.log("Both WebAssembly and asm.js Olm failed!", legacyLoadError);
117-
});
118-
});
119-
}
120-
12175
export async function loadLanguage(): Promise<void> {
12276
const prefLang = SettingsStore.getValue("language", null, /*excludeDefault=*/ true);
12377
let langs: string[] = [];

webpack.config.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ module.exports = (env, argv) => {
274274
// there is no need for webpack to parse them - they can just be
275275
// included as-is.
276276
/highlight\.js[\\/]lib[\\/]languages/,
277-
278-
// olm takes ages for webpack to process, and it's already heavily
279-
// optimised, so there is little to gain by us uglifying it.
280-
/olm[\\/](javascript[\\/])?olm\.js$/,
281277
],
282278
rules: [
283279
useHMR && {
@@ -443,20 +439,6 @@ module.exports = (env, argv) => {
443439
},
444440
],
445441
},
446-
{
447-
// the olm library wants to load its own wasm, rather than have webpack do it.
448-
// We therefore use the `file-loader` to tell webpack to dump the contents to
449-
// a separate file and return the name, and override the default `type` for `.wasm` files
450-
// (which is `webassembly/experimental` under webpack 4) to stop webpack trying to interpret
451-
// the filename as webassembly. (see also https://github.com/webpack/webpack/issues/6725)
452-
test: /olm\.wasm$/,
453-
loader: "file-loader",
454-
type: "javascript/auto",
455-
options: {
456-
name: "[name].[hash:7].[ext]",
457-
outputPath: ".",
458-
},
459-
},
460442
{
461443
// Fix up the name of the opus-recorder worker (react-sdk dependency).
462444
// We more or less just want it to be clear it's for opus and not something else.
@@ -498,8 +480,11 @@ module.exports = (env, argv) => {
498480
},
499481
},
500482
{
501-
// Same deal as olm.wasm: the decoderWorker wants to load the wasm artifact
502-
// itself.
483+
// The decoderWorker wants to load its own wasm, rather than have webpack do it.
484+
// We therefore use the `file-loader` to tell webpack to dump the contents to
485+
// a separate file and return the name, and override the default `type` for `.wasm` files
486+
// (which is `webassembly/experimental` under webpack 4) to stop webpack trying to interpret
487+
// the filename as webassembly. (see also https://github.com/webpack/webpack/issues/6725)
503488
test: /decoderWorker\.min\.wasm$/,
504489
loader: "file-loader",
505490
type: "javascript/auto",
@@ -750,7 +735,6 @@ module.exports = (env, argv) => {
750735
{ from: "vector-icons/**", context: path.resolve(__dirname, "res") },
751736
{ from: "decoder-ring/**", context: path.resolve(__dirname, "res") },
752737
{ from: "media/**", context: path.resolve(__dirname, "node_modules/matrix-react-sdk/res/") },
753-
"node_modules/@matrix-org/olm/olm_legacy.js",
754738
{ from: "config.json", noErrorOnMissing: true },
755739
"contribute.json",
756740
],

0 commit comments

Comments
 (0)