Skip to content

dart2wasm supportΒ #230

@simolus3

Description

@simolus3

Current state: package:sqlite3 experimentally supports being compiled with dart2wasm. Unit tests exercising the bindings themselves all pass, but persistence is broken. There are additional caveats and todos to be aware of:

  • (fixed in upcoming Dart SDK release) dart2wasm doesn't seem to support Random.secure(), which we use for our VFS implementations. You can work around this issue by supplying your own non-secure Random() instance to VFS constructors, but please be aware that this may be a security risk. sqlite3 docs require that "The xRandomness() function attempts to return nBytes bytes of good-quality randomness into zOut", so I won't use the non-secure random instance as a default in this package.
  • When binding over web APIs returning JavaScript ArrayBuffers, we're converting them to Dart TypedData subclasses for convenience. This is not sound for dart2wasm, which copies the bytes instead of referencing the original buffer. This may just be hugely inefficient, but it can also cause deadlocks for OPFS and data corruption issues on other VFS implementations.
  • We're currently loading an additional wasm module for sqlite3 (sqlite3.wasm). Once the native assets feature is stable and supports WebAssembly, obviously we want to link the Dart application and sqlite3 into the same wasm file for easier deployments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions