This document tracks the implementation of the Model Management API for the React Native Vision SDK.
Last Updated: 2025-12-15 Implementation: TypeScript 100%, iOS 100%, Android 100% Testing: Verified in Example App (ModelManagementScreen.tsx, HomeScreen.tsx)
-
Types (
src/types.ts):OCRModule- Model configuration typeExecutionProvider- Android execution provider enumModelManagerConfig- Initialization configurationDownloadProgress- Download progress trackingModelInfo- Model metadataModelUpdateInfo- Update check resultsModelException- Error typesModelLifecycleListener- Lifecycle callbacks
-
TurboModule Spec (
src/specs/NativeVisionSdkModule.ts):- All 16 method signatures defined
- Event emitter methods (addListener, removeListeners)
-
Wrapper Implementation (
src/VisionCoreWrapper.ts):initializeModelManager()- Initialize singletonisModelManagerInitialized()- Check initialization statusdownloadModel()- Download with progress trackingcancelDownload()- Cancel active downloadgetActiveDownloadCount()- Query download countloadOCRModel()- Load model into memoryunloadModel()- Unload from memoryisModelLoaded()- Check if loadedgetLoadedModelCount()- Query loaded countfindDownloadedModels()- List all downloadedfindDownloadedModel()- Find specific modelfindLoadedModels()- List all loadedcheckModelUpdates()- Check for updatesdeleteModel()- Delete from diskpredictWithModule()- Predict with specific model
- File:
android/src/newarch/java/com/visionsdk/VisionSdkModule.kt - Status: All 15 methods fully implemented and tested
- SDK Version: Updated to support Model Management API
Helper Functions (Ready):
parseOCRModule()- JSON to OCRModule conversionparsePlatformType()- String to PlatformType enumparseExecutionProvider()- String to ExecutionProvider enum (defaults to CPU)modelInfoToJson()- ModelInfo serializationmodelInfoListToJson()- List serializationmodelUpdateInfoToJson()- UpdateInfo serializationsendDownloadProgressEvent()- Progress eventssendModelLifecycleEvent()- Lifecycle event emitter (commented out)modelLifecycleListener- Lifecycle callback handler (commented out)
- File:
ios/VisionSdkModule.swift,ios/VisionSdkModuleTurboModule.mm - Status: All 15 methods fully implemented and tested
- Event Emitters: Progress tracking and lifecycle events functional
-
Initialization & Configuration
initializeModelManager()- Singleton pattern with configurable options (Android only - iOS is hardcoded no-op)isModelManagerInitialized()- Status checking (Android only - iOS always returnstrue)
-
Download Management
downloadModel()- Isolated progress tracking per modelcancelDownload()- Cancel in-progress downloads- Progress events with model-specific callbacks
-
Model Loading
loadOCRModel()- Load into memory with execution provider selection- Support for CPU, NNAPI, XNNPACK on Android
- Automatic model download if not present
-
Memory Management
unloadModel()- Unload from memory (returns boolean)isModelLoaded()- Check load statusgetLoadedModelCount()- Count loaded models
-
Model Discovery
findDownloadedModels()- List all downloaded modelsfindDownloadedModel()- Find specific modelfindLoadedModels()- List currently loaded models
-
Model Lifecycle
deleteModel()- Permanent deletion from disk
-
Prediction with Module Selection
predictWithModule()- Predict with specific model- Dynamic model switching without reconfiguration
The example app includes a comprehensive ModelManagementScreen.tsx that demonstrates:
- All 15 API methods
- Concurrent operations (download 3 models simultaneously)
- Progress tracking for multiple downloads
- Error handling patterns
- UI state management
import VisionCore from 'react-native-vision-sdk';
// Initialize first
VisionCore.initializeModelManager({
maxConcurrentDownloads: 2,
enableLogging: true
});
// Download with progress tracking
await VisionCore.downloadModel(
{ type: 'shipping_label', size: 'large' },
apiKey,
token,
(progress) => {
console.log(`${progress.module.type}: ${progress.progress * 100}%`);
}
);// Load model with CPU execution provider (Android only)
await VisionCore.loadOCRModel(
{ type: 'shipping_label', size: 'large' },
apiKey,
token,
'CPU' // Defaults to CPU if not specified
);
// Check if loaded
const isLoaded = VisionCore.isModelLoaded({
type: 'shipping_label',
size: 'large'
});
// Make prediction with specific model
const result = await VisionCore.predictWithModule(
{ type: 'shipping_label', size: 'large' },
imageUri,
['1234567890']
);src/types.ts- Added 8 new typessrc/specs/NativeVisionSdkModule.ts- Added 16 method signaturessrc/VisionCoreWrapper.ts- Added 16 methods + deprecated 3 old methods
android/src/newarch/java/com/visionsdk/VisionSdkModule.kt- Added:- 15 method stubs
- Helper functions for JSON serialization
- Event emitters for progress and lifecycle
- Lifecycle listener (commented out)
android/build.gradle- No changes (SDK version unchanged)android/gradle.properties- Updated compileSdk/targetSdk to 36example/android/build.gradle- Updated compileSdk/targetSdk to 36
Once unobfuscated SDK is available:
-
Unit Tests:
- Test parseOCRModule with various inputs
- Test JSON serialization helpers
- Test event emission
-
Integration Tests:
- Initialize ModelManager
- Download a model with progress tracking
- Load model with different execution providers
- Query downloaded/loaded models
- Check for updates
- Delete model
-
E2E Tests:
- Full workflow: initialize → download → load → predict → unload → delete
- Concurrent downloads (2 models)
- Lifecycle event tracking
-
iOS - Initialization Methods
initializeModelManager()- Hardcoded no-op, does nothingisModelManagerInitialized()- Hardcoded to always returntrue- These methods exist only for API consistency with Android
- iOS does not require initialization, models work without calling these methods
-
Android - Execution Provider
- Supports CPU, NNAPI, XNNPACK for model execution
- Defaults to CPU for maximum compatibility
- iOS doesn't expose execution provider selection
-
API Consistency
- Some Android native methods (e.g.,
getActiveDownloadCount()) not available in iOS - These are commented out in wrapper to maintain cross-platform consistency
- Some Android native methods (e.g.,
// Initialize (required on Android)
await VisionCore.initializeModelManager({ maxConcurrentDownloads: 2 });
// Download and load model
await VisionCore.downloadModel({ type: 'shipping_label', size: 'large' }, apiKey, token);
await VisionCore.loadOCRModel({ type: 'shipping_label', size: 'large' }, apiKey, token);
// Make predictions
const result = await VisionCore.predictWithModule(
{ type: 'shipping_label', size: 'large' },
imageUri,
barcodes
);
// Cleanup
await VisionCore.unloadModel({ type: 'shipping_label', size: 'large' });
await VisionCore.deleteModel({ type: 'shipping_label', size: 'large' });For questions about:
- Obfuscated SDK: Contact VisionSDK team for unobfuscated SNAPSHOT or release
- Implementation: Review this document and the MODEL_MANAGEMENT_API_REFERENCE.md
Last Updated: 2025-12-13 Status: Awaiting unobfuscated Android SDK Completion: TypeScript 100%, Android Stubs 100%, iOS 0%