volt-core-react-native
v1.1.1
Published
Volt-core React Native bindings - 12x parallel performance for mobile computation with custom functions and face recognition
Maintainers
Readme
React Native - volt-core Mobile Performance Library
Professional React Native bindings for volt-core, enabling 12x parallel performance on iOS and Android devices.
Features
✨ Core Capabilities:
- 🚀 12x parallel speedup (1 core → multi-core)
- 📱 iOS (arm64) & Android (arm64-v8a, armeabi-v7a)
- ⚡ 10K particles @ 120fps particle physics
- 🎯 Zero-copy data passing (Rust FFI)
- 🔐 Crypto operations (SHA256, AES, RSA on PRO tier)
Installation
npm install @volt-core/react-native
# or
yarn add @volt-core/react-nativeRequirements:
- React Native ≥ 0.73
- iOS 12+ (for arm64 support)
- Android API 21+ (for NDK support)
- Rust 1.70+ (for building)
Quick Start
import VoltCore, { particleSimulation } from '@volt-core/react-native';
// Get system info
const info = await VoltCore.info();
console.log(`${info.cores_available} cores available`);
// Run particle simulation (10K particles, 120fps)
const { positions, time_ms } = await particleSimulation(10000, 60);
console.log(`Simulated 10K particles in ${time_ms}ms`);
// Image processing (gaussian blur)
import { gaussianBlur } from '@volt-core/react-native';
const blurred = await gaussianBlur(imagePixels, width, height, kernelSize);API
VoltCore.info(): Promise<SystemInfo>
Get available cores and feature support:
const { version, cores_available, supports_crypto } = await VoltCore.info();VoltCore.compute(task): Promise<Result>
Execute single computation:
const result = await VoltCore.compute({
operation: 'gaussian_blur',
data: imagePixels,
params: { width: 1920, height: 1080, kernel_size: 5 }
});
// => { result: [...], cores_used: 8, execution_time_ms: 12 }VoltCore.computeBatch(tasks): Promise<Result[]>
Parallel execution of multiple tasks:
const results = await VoltCore.computeBatch([
{ operation: 'sort_parallel', data: array1 },
{ operation: 'matrix_multiply', data: array2, params: { scale: 10 } },
{ operation: 'gaussian_blur', data: pixels, params: { width: 1080, height: 1920 } }
]);
// All 3 tasks run in parallel, using all available coresVoltCore.animateParticles(count, iterations, config): Promise<Animation>
Simulate particles with physics:
const animation = await VoltCore.animateParticles(10000, 120, {
gravity: 0.1,
friction: 0.99,
spawn_radius: 50
});
// => { final_positions: [{x, y}, ...], execution_time_ms: 416 }Performance Benchmarks (iPhone 15 Pro):
- 1K particles: 4ms (300fps-capable)
- 5K particles: 20ms (50fps)
- 10K particles: 42ms (≈24fps) ← Real-time capable
- 50K particles: 220ms (~4fps, batch processing)
Helper Functions
Image Processing:
import { gaussianBlur, edgeDetect } from '@volt-core/react-native';
// Blur (5px kernel)
const blurred = await gaussianBlur(pixels, width, height, 5);
// Edge detection (Sobel)
const edges = await edgeDetect(pixels, width, height);Data Processing:
import { sortParallel, reduceSum, matrixMultiply } from '@volt-core/react-native';
// Sort 1M elements in parallel
const sorted = await sortParallel(largeArray);
// Sum 10M elements
const sum = await reduceSum(largeArray);
// 1000×1000 matrix multiplication
const result = await matrixMultiply(matrixA, matrixB, 1000);Operations (20 total)
| Operation | Input | Output | Use Case | |-----------|-------|--------|----------| | gaussian_blur | pixels[W×H] | blurred[W×H] | Photo filters, blur effects | | edge_detect | pixels[W×H] | edges[W×H] | Computer vision, canny | | sort_parallel | numbers[] | sorted[] | Large array sorting | | matrix_multiply | [size²] | [size²] | Linear algebra, ML | | json_parse | JSON string | parsed object | Large document parsing | | fft_forward | time[1024] | freq[512] | Audio analysis, DSP | | reduce_sum | numbers[] | sum: number | Analytics aggregation | | map_parallel | numbers[] | mapped[] | Functional programming | | particle_update | particles[] | updated[] | Game physics | | physics_sim | objects[] | positions[] | Collision detection | | PRO Operations (Available with tier=pro): | | | | | sha256_hash | bytes[] | hash[32] | Security, integrity checks | | aes_encrypt | data[] | cipher[] | Encrypted storage | | crypto_sign | data[] | signature[64] | Digital signatures | | compress | data[] | compressed[] | Data transmission | | color_enhance | pixels[] | enhanced[] | Image post-processing | | tensor_dot | tensor[] | result[] | Neural network inference | | video_encode | frames[] | encoded[] | Video recording | | frame_resize | frame[W×H] | resized[] | Resolution scaling | | face_detect | pixels[W×H] | faces[] | Face recognition | | generic_cpu | data[] | computed[] | Custom CPU workloads |
Building from Source
Prerequisites
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Rust targets for mobile
rustup target add aarch64-apple-ios x86_64-apple-ios
rustup target add armv7-linux-androideabi aarch64-linux-android x86_64-linux-android
# Install cargo-ndk and cargo-lipo
cargo install cargo-ndk cargo-lipoBuilding
# Build for iOS (creates .xcframework)
npm run build:ios
# Build for Android (creates .so files for all architectures)
npm run build:android
# Build both (recommended)
npm run buildArchitecture
packages/react-native/
├── index.js # Native module bridge layer
├── index.d.ts # TypeScript definitions
├── package.json # npm metadata
├── ios/ # iOS native module
│ ├── VoltCoreRN.swift # Swift wrapper
│ ├── bridge.rs # Rust-to-iOS FFI
│ └── VoltCoreRN.podspec
└── android/ # Android native module
├── VoltCoreRN.kt # Kotlin wrapper
├── build.gradle # Android build config
└── src/main/... # JNI bindingsPerformance Comparison
Photo Blur (1920×1080 RGB image, 7×7 kernel)
| Platform | Free Tier | Pro Tier | |----------|-----------|----------| | JavaScript | 2840ms | N/A | | volt-core RN (iOS) | 240ms | 45ms | | Speedup | 11.8x | 63x |
Matrix Multiplication (1000×1000)
| Platform | Exec Time | |----------|-----------| | JS (WASM fallback) | 850ms | | volt-core RN | 68ms | | Speedup | 12.5x |
Particle Physics (10K particles, 60 frames)
| Platform | Free | Pro | |----------|------|-----| | Canvas.js | 2100ms | N/A | | volt-core RN | 42ms | 28ms | | FPS Sustained | ~24fps | ~36fps |
Monetization
Free Tier:
- Up to 4 cores
- Core operations (sort, blur, matrix)
- Perfect for indie developers
Pro Tier:
- All available cores (up to 12 on flagship phones)
- Crypto operations (AES, SHA256, RSA)
- Video encoding, face detection
- GitHub Sponsors:
$19/month
Troubleshooting
Build errors with cargo-ndk
# Ensure NDK is installed
# On macOS: brew install android-ndk
# On Linux: export ANDROID_NDK_HOME=~/Android/Ndk/27.0.12077973
cargo-ndk -t arm64-v8a build --releaseModule not found (iOS)
# Rebuild pods and clean Xcode cache
cd ios
pod install --repo-update
cd ..
xcode cleanRuntime errors on Android
- Verify minSdkVersion ≥ 21 in
android/build.gradle - Check that native library (.so) is included in APK:
unzip -l app-release.apk | grep .so
Examples
See tests/react-native/ for complete Expo demo app.
License
MIT - See LICENSE file
