element-web icon indicating copy to clipboard operation
element-web copied to clipboard

Element-R: hang during login

Open richvdh opened this issue 2 years ago • 5 comments

Sometimes, when attempting to log in, you get faced with a spinner of doom:

image

I think it's something indexedDB related. From the logs:

16:00:02.449 Removing indexeddb instance: matrix-js-sdk:crypto [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)
16:00:02.450 Removing IndexedDB instance matrix-js-sdk::matrix-sdk-crypto [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)
16:00:02.451 Removed indexeddb instance: matrix-js-sdk:crypto [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)
16:00:02.452 cannot yet remove IndexedDB instance matrix-js-sdk::matrix-sdk-crypto [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)
16:00:02.551 IndexedDB worker is ready [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)
16:00:02.551 Removing indexeddb instance: matrix-js-sdk:riot-web-sync [959eaaf02cce2e15d078.worker.js:5127:33](https://pr10080--matrix-react-sdk.netlify.app/959eaaf02cce2e15d078.worker.js)
16:00:02.552 Removed indexeddb instance: matrix-js-sdk:riot-web-sync [959eaaf02cce2e15d078.worker.js:5127:33](https://pr10080--matrix-react-sdk.netlify.app/959eaaf02cce2e15d078.worker.js)
16:00:02.553 Deleted indexeddb data. [rageshake.ts:74:27](webpack:///src/rageshake/rageshake.ts)

​ note cannot yet remove IndexedDB instance in particular.

It's fine after a reload.

richvdh avatar Jul 12 '23 15:07 richvdh

This is back

richvdh avatar Oct 04 '23 15:10 richvdh

There is a test that is supposed to catch this (MatrixClient.clearStores > should clear the indexeddbs in matrix-js-sdk/spec/integ/crypto/rust-crypto.spec.ts). Once we find the leak, we should extend the test to reproduce the problem area.

richvdh avatar Oct 05 '23 17:10 richvdh

I now can't reproduce this.

richvdh avatar Oct 20 '23 21:10 richvdh

We're still seeing this intermittently

richvdh avatar Jun 20 '24 09:06 richvdh

The root cause here is failures to clean up objects on the rust side during logout, which means we end up holding onto a connection to the IndexedDB. That means that we can't delete the IndexedDB, and when we log in again, attempts to open the IndexedDB block indefinitely.

The reason that the Rust objects aren't being cleaned up is that we're relying on javascript's FinalizationRegistry to call the rust-side destructors. As the MDN page makes clear, that mechanism is unreliable.

We could attempt to explicitly call .free on every reference to a Rust object that is ever passed to the JS layer (as we did for a specific case with https://github.com/matrix-org/matrix-js-sdk/pull/3610), but that is likely to add a lot of boilerplate, and be very brittle.

A more plausible solution is to update the matrix-rust-sdk IndexeddbCryptoStore so that it doesn't maintain a connection to the Indexeddb throughout its lifetime, but rather opens a new one each time an operation is performed. Opening the Indexeddb is quick enough that this shouldn't have a significant performance impact.

richvdh avatar Jun 20 '24 09:06 richvdh

@richvdh @t3chguy please fix this problem or maybe u can find someone to make a new pull request as i often clean up cached files including indexeddb and when i opened out element and sign in again it blocked sign in and lead to this problem.

gmanskibiditoilet avatar Feb 14 '25 09:02 gmanskibiditoilet

@gmanskibiditoilet what does this issue have to do with me? If you continue to randomly tag me I'll just block you so I don't get notifications unrelated to anything I'm involved with while I'm on holiday.

t3chguy avatar Feb 14 '25 10:02 t3chguy

@gmanskibiditoilet what does this issue have to do with me? If you continue to randomly tag me I'll just block you so I don't get notifications unrelated to anything I'm involved with while I'm on holiday.

ok sorry

gmanskibiditoilet avatar Feb 14 '25 11:02 gmanskibiditoilet