Skip to main content

Boost SDK Performance with WebAssembly

Learn how WebAssembly (Wasm) dramatically improves SDK performance for mobile apps, especially for resource-intensive tasks like liveness detection. Explore benefits, implementation, and optimization strategies.

Boost SDK Performance with WebAssembly

Contents

In this guide

Jump to the part you need.

Boost SDK Performance with WebAssembly

In today's mobile landscape, performance is paramount. Users demand fast, responsive applications, and even slight delays can lead to frustration and churn. SDKs, while providing crucial functionality like identity verification and liveness detection, can often be a significant source of performance bottlenecks. WebAssembly (Wasm) offers a powerful solution to address these challenges, enabling developers to deliver high-performance SDK integrations with reduced app size and improved battery life.

Key Takeaway 1 Wasm allows you to run near-native code in the browser and mobile apps, significantly improving SDK performance.

Key Takeaway 2 Integrating Wasm can drastically reduce the size of SDKs, leading to faster download and installation times.

Key Takeaway 3 Wasm enhances security by providing a sandboxed execution environment for SDK components.

Key Takeaway 4 Using Wasm allows for cross-platform compatibility, simplifying development and maintenance.

What is WebAssembly?

WebAssembly is a binary instruction format designed to be a portable compilation target for high-level languages like C, C++, Rust, and others. Initially created to improve web application performance, its benefits extend far beyond the browser. Unlike JavaScript, which is interpreted at runtime, Wasm is compiled into native machine code, resulting in significantly faster execution speeds. This makes it ideal for computationally intensive tasks that are commonly found in SDKs.

Traditionally, SDKs were delivered as JavaScript libraries. While convenient, JavaScript’s interpreted nature often resulted in performance limitations, particularly on lower-powered mobile devices. Wasm bypasses this limitation by providing a near-native execution environment. This is particularly crucial for resource-intensive tasks like image processing, video analysis (common in liveness detection), and complex calculations.

The Performance Benefits of Wasm for SDKs

The advantages of using WebAssembly for SDK optimization are substantial. Consider a liveness detection SDK, which often involves analyzing video streams and performing facial recognition. A JavaScript-based implementation might struggle to maintain a smooth frame rate on older devices, leading to a poor user experience. By rewriting the core liveness detection algorithms in C++ and compiling them to Wasm, you can achieve:

  • Faster Execution Speed: Wasm code executes significantly faster than equivalent JavaScript code.
  • Reduced App Size: Wasm binaries are typically smaller than JavaScript bundles, reducing download and installation sizes. This is especially important for mobile apps where bandwidth and storage are limited.
  • Improved Battery Life: Faster execution and reduced CPU usage translate to lower power consumption and longer battery life.
  • Enhanced Security: Wasm runs in a sandboxed environment, isolating it from the host system and reducing the risk of malicious code execution.

For example, Didit’s core liveness detection engine is partially implemented in Wasm, resulting in a 30-40% performance improvement on Android devices compared to a purely JavaScript implementation. This translates to faster verification times and a smoother user experience.

Implementing Wasm in Your Mobile SDK

Integrating WebAssembly into your mobile SDK requires careful planning and consideration. Here’s a breakdown of the key steps:

  1. Choose a Suitable Language: C, C++, and Rust are popular choices for writing Wasm modules.
  2. Compile to Wasm: Use a compiler like Emscripten (for C/C++) or wasm-pack (for Rust) to compile your code to a .wasm file.
  3. Load and Instantiate the Wasm Module: Use the WebAssembly JavaScript API to load and instantiate the Wasm module in your application.
  4. Communicate with the Wasm Module: Define a clear interface for communication between your JavaScript code and the Wasm module. This typically involves passing data as numerical values or using shared memory.

Code Example (JavaScript):


  async function loadWasmModule() {
    const response = await fetch('liveness_detection.wasm');
    const bytes = await response.arrayBuffer();
    const { instance } = await WebAssembly.instantiate(bytes, {});
    return instance.exports;
  }

  async function runLivenessDetection() {
    const wasmModule = await loadWasmModule();
    const videoFrame = // ... get video frame data
    const result = wasmModule.detectLiveness(videoFrame);
    // ... process result
  }

Optimizing Wasm Modules for Mobile Performance

While Wasm offers significant performance benefits, it’s crucial to optimize your modules for mobile devices. Here are some key optimization techniques:

  • Minimize Module Size: Remove unnecessary code and data from your Wasm module.
  • Use Efficient Data Structures: Choose data structures that are well-suited for Wasm’s memory model.
  • Optimize Memory Access: Minimize memory fragmentation and ensure efficient access patterns.
  • Profile and Benchmark: Use profiling tools to identify performance bottlenecks and optimize accordingly.

How Didit Helps

Didit leverages WebAssembly to deliver a high-performance, secure, and reliable identity verification experience. Our core liveness detection engine and other critical components are implemented in Wasm, resulting in:

  • Faster Verification Times: Reduced latency for a smoother user experience.
  • Improved Conversion Rates: Faster verification leads to fewer drop-offs.
  • Reduced Fraud: More reliable liveness detection minimizes the risk of spoofing attacks.
  • Lower Operational Costs: Efficient SDKs reduce server load and infrastructure costs.

We provide a comprehensive SDK with WebAssembly integration, allowing you to seamlessly integrate our identity verification services into your mobile applications.

Ready to Get Started?

Ready to experience the performance benefits of WebAssembly for your mobile SDK?

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Blog questions

Who writes the Didit blog?
The Didit team. Guides reviewed by Alberto Rosas, co-founder and CEO, carry his byline. The rest are published as Didit.
Which topics does the blog cover?
Eight topics: ID verification, business verification (KYB), AML, sanctions and compliance, fraud prevention, transaction monitoring and crypto, country guides, agents and developers, and product updates.
Is the blog available in my language?
Yes, in 15 languages: English, Spanish, French, German, Brazilian and European Portuguese, Catalan, Russian, Arabic, Chinese, Japanese, Hindi, Indonesian, Korean and Swahili. Not every post is translated, so each language shows the posts it has.
Where do I find product updates?
In the changelog at /changelog/ and under the Product updates topic.
Are these posts legal advice?
No. Regulation posts explain rules; your legal team decides how they apply.
How do I find posts on one topic?
Open one of the eight topics, or search the blog.
Are posts dated?
Yes. Every post shows when it was published and when it was last updated.
Do posts link to the docs?
Developer posts link to the matching page on docs.didit.me and to the API reference.
Is the blog the same as the docs?
No. The blog explains rules, markets and product changes for a general reader, while docs.didit.me holds the integration guides and the API reference. Developer posts link the matching docs page and the API reference they describe.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.