Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autonomi): run self encryption non-blocking #2397

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

b-zee
Copy link
Contributor

@b-zee b-zee commented Nov 6, 2024

Previously, the encrypt method might block other tasks from
progressing in the same runtime (thread).

In JS this would cause an issue as it's single threaded, meaning the UI
got blocked during encryption

Has to be compiled using nightly compiler arguments, e.g. to run tests:

RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' CARGO_TARGET_DIR=/home/zamaan/src/safe_network/target/wasm wasm-pack test --release --firefox autonomi -Z build-std=std,panic_abort --test wasm

b-zee added 2 commits November 6, 2024 16:08
Previously, the `encrypt` method might block other tasks from
progressing in the same runtime (thread).

In JS this would cause an issue as it's single threaded, meaning the UI
got blocked during encryption
@b-zee b-zee enabled auto-merge November 7, 2024 13:21
@b-zee b-zee added this pull request to the merge queue Nov 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 8, 2024
@b-zee b-zee added this pull request to the merge queue Nov 19, 2024
Merged via the queue into maidsafe:main with commit c295c9d Nov 19, 2024
28 checks passed
@b-zee b-zee deleted the feat-non-blocking-self-encrypt-client-api branch November 19, 2024 12:46
@mickvandijke
Copy link
Contributor

mickvandijke commented Nov 20, 2024

Unfortunately I did not test this properly before approving. When I tried to actually use it in the webapp it caused quite some problems.

First I needed a way for Nuxt/Vite to enable the SharedArrayBuffer in a local dev environment. I tried many proposed solutions, but none of them worked. Eventually got a working setup like this in the nuxt.config.ts file:

export default defineNuxtConfig({
  ...
  nitro: {
    routeRules: {
      '/**': {
        headers: {
          'Cross-Origin-Embedder-Policy': 'require-corp',
          'Cross-Origin-Opener-Policy': 'same-origin'
        },
      },
    },
  },
  ...
})

We might have to do something similar on the platform we deploy the static site at.

Then I ran into this error on Chrome:

RuntimeError: Atomics.wait cannot be called in this context

And this error on Firefox:

TypeError: waiting is not allowed on this thread

I don't think the Chrome error is fixable. The Firefox error we might be able to fix, but I haven't found a solution yet.

So I propose that we rollback this PR and potentially deal with the sync encryption in the API consumer side instead of within the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants