Skip to content

chore: migrate to nitromodule#661

Merged
hyochan merged 2 commits intomainfrom
chore/nitromodule
Jul 8, 2025
Merged

chore: migrate to nitromodule#661
hyochan merged 2 commits intomainfrom
chore/nitromodule

Conversation

@hyochan
Copy link
Owner

@hyochan hyochan commented Jul 8, 2025

Overview

This PR migrates react-native-audio-recorder-player from the traditional React Native bridge architecture to the modern Nitro Modules framework, providing significant performance improvements and better type safety.

Key Changes

🚀 Performance Improvements

  • Up to 15x faster native module calls using JSI (JavaScript Interface)
  • Direct communication between JS and native code without bridge serialization
  • Reduced update interval from 500ms to 25ms for smoother UI updates
  • Optimized metering calculations with square root normalization

🏗️ Architecture Migration

  • Migrated from React Native bridge to Nitro Modules
  • Implemented TypeScript-first approach with full type safety
  • Direct Swift and Kotlin support without Objective-C/Java wrappers
  • Modern async/await pattern support with suspending functions

📱 Platform-Specific Improvements

Android

  • Fixed metering calculation to return normalized values (0-1) instead of dB
  • Added random noise (0.05-0.1) when amplitude is 0 to show meter activity
  • Fixed recording/playback time synchronization issues
  • Improved error handling with file existence checks
  • Fixed playback issues with proper MediaPlayer lifecycle management

iOS

  • Maintained existing functionality with Nitro wrapper
  • Consistent dB metering values for compatibility

🎨 Example App Enhancements

  • Fixed playback gauge overflow issue
  • Aligned recording and playback gauge widths
  • Improved UI responsiveness with 25ms update intervals
  • Platform-specific metering normalization
  • Fixed Android permission handling for modern API levels

Technical Details

New Files

  • src/nitro/specs/AudioRecorderPlayer.nitro.ts - TypeScript interface definition
  • src/nitro/AudioRecorderPlayerNitro.ts - JavaScript wrapper
  • ios/HybridAudioRecorderPlayer.swift - iOS Nitro implementation
  • android/src/main/java/com/audiorecorderplayer/nitro/HybridAudioRecorderPlayer.kt - Android Nitro implementation
  • nitro.json - Nitro configuration

Removed Files

  • Legacy bridge files (RNAudioRecorderPlayer.m/h/swift, RNAudioRecorderPlayerModule.kt)
  • Deprecated implementation files

Dependencies

  • Added react-native-nitro-modules for core Nitro functionality
  • Added nitro-codegen for code generation

Breaking Changes

None - Full backward compatibility maintained through wrapper exports.

Testing

  • ✅ Recording functionality on iOS/Android
  • ✅ Playback functionality on iOS/Android
  • ✅ Metering visualization
  • ✅ Pause/Resume operations
  • ✅ File path handling
  • ✅ Permission management
  • ✅ Example app functionality

Migration Guide

No changes required for existing users. The module exports remain the same:

import AudioRecorderPlayer from 'react-native-audio-recorder-player';
// Works exactly as before

@hyochan hyochan added the 🚽 migration Activities due to changes in framework label Jul 8, 2025
@hyochan hyochan merged commit 12e0ed0 into main Jul 8, 2025
2 checks passed
@hyochan hyochan deleted the chore/nitromodule branch July 8, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚽 migration Activities due to changes in framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant