Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
877 stars 570 forks source link

[BUG]: Crash after calling setSubscriptionDuration #800

Open jcblancomartinez opened 2 years ago

jcblancomartinez commented 2 years ago

Flutter Sound Version :

|-- flutter_sound 8.4.2 | |-- flutter_sound_platform_interface 8.4.2 | |-- flutter_sound_web 8.4.2 | | |-- flutter_sound_platform_interface...


Severity


Platforms you faced the error


Describe the bug My app is crashing when calling setSubscriptionDuration. I'm loading multiple FlutterSoundPlayer instances in the same page.

To Reproduce Steps to reproduce the behavior:

  1. Enter a page
  2. Crash happens
Future<void> _asyncInit() async {
  try {
    await _audioPlayer.openAudioSession(
        withUI: false,
        focus: AudioFocus.requestFocusAndStopOthers,
        category: SessionCategory.playAndRecord,
        mode: SessionMode.modeDefault,
        device: AudioDevice.speaker);
    if (!await _audioPlayer.isDecoderSupported(widget._codec)) {
      throw Exception('Unsupported codec=[${widget._codec}]');
    }
    await _audioPlayer.setSubscriptionDuration(Duration(milliseconds: 100));
    _audioPlayerSubscription = _audioPlayer.onProgress?.listen((e) {
      setState(() {
        // We are applying the min to avoid situations where e.position is greater
        // than _audioDuration and an exception is thrown.
        _currentMillisecond = _audioDuration == null
            ? e.position.inMilliseconds.toDouble()
            : min(_audioDuration!.inMilliseconds, e.position.inMilliseconds)
                .toDouble();
      });
    });
    Duration? audioDuration = await widget._audioDurationProvider
        .getAudioDuration(widget._audioSrc);
    if (mounted) {
      setState(() {
        _audioDuration = audioDuration;
        _state = WidgetState.loaded;
      });
    }
  } catch (e) {
    if (mounted) {
      setState(() {
        _state = WidgetState.error;
      });
    }
    rethrow;
  }
}

Logs!!!!

Last Exception Backtrace: 0 CoreFoundation 0x1805d99d4 exceptionPreprocess + 216 (NSException.m:199) 1 libobjc.A.dylib 0x193f8ab54 objc_exception_throw + 56 (objc-exception.mm:565) 2 CoreFoundation 0x1804e9bac -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:146) 3 CoreFoundation 0x1805dc018 __forwarding + 1440 (NSForwarding.m:3597) 4 CoreFoundation 0x1805ddf8c _CF_forwarding_prep_0 + 92 5 Runner 0x100540258 -[fluttersoundplayermanager handlemethodcall:result:] + 1508 (FlutterSoundPlayerManager.mm:151) 6 Flutter 0x10303615c 0x102b34000 + 5251420 7 Flutter 0x102b71020 0x102b34000 + 249888 8 Flutter 0x102eeec88 0x102b34000 + 3910792 9 Flutter 0x102e1df40 0x102b34000 + 3055424 10 Flutter 0x102e2150c 0x102b34000 + 3069196 11 CoreFoundation 0x18055a3d0 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28 (CFRunLoop.c:1807) 12 CoreFoundation 0x180559fd4 CFRunLoopDoTimer + 1004 (CFRunLoop.c:2415) 13 CoreFoundation 0x1805594b4 CFRunLoopDoTimers + 324 (CFRunLoop.c:2575) 14 CoreFoundation 0x180553840 __CFRunLoopRun + 1912 (CFRunLoop.c:3090) 15 CoreFoundation 0x180552b90 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242) 16 GraphicsServices 0x196875598 GSEventRunModal + 160 (GSEvent.c:2259) 17 UIKitCore 0x182e3c638 -[UIApplication _run] + 1052 (UIApplication.m:3266) 18 UIKitCore 0x182e41bb8 UIApplicationMain + 164 (UIApplication.m:4738) 19 Runner 0x100519920 main + 64 (AppDelegate.swift:6) 20 libdyld.dylib 0x180231588 start + 4

Thread 3 name: Thread 3: 0 libsystem_kernel.dylib 0x00000001ab605644 psynch_mutexdrop + 8 1 libsystem_pthread.dylib 0x00000001c6c33180 _pthread_mutex_firstfit_wake + 24 (pthread_mutex.c:1317) 2 libsystem_pthread.dylib 0x00000001c6c3314c _pthread_mutex_firstfit_unlock_slow$VARIANT$mp + 256 (pthread_mutex.c:1346) 3 libc++.1.dylib 0x00000001940559fc std::1::mutex::unlock() + 12 (threading_support:369) 4 Flutter 0x0000000102e1e79c 0x102b34000 + 3057564 5 Flutter 0x0000000102eec2b8 0x102b34000 + 3900088 6 Flutter 0x0000000102ee34f8 0x102b34000 + 3863800 7 Flutter 0x0000000103031b70 0x102b34000 + 5233520 8 Flutter 0x0000000102fdff74 0x102b34000 + 4898676 9 Flutter 0x00000001030a1ad0 0x102b34000 + 5692112 10 App 0x0000000105786314 Precompiled_Stub_CallAutoScopeNative + 80 11 App 0x00000001057dba80 Precompiled_PlatformDispatchersendPlatformMessage_16065589_1509 + 68 12 App 0x00000001057dbd1c Precompiled_PlatformDispatcher_sendPlatformMessage_1515 + 64 13 App 0x000000010583b3ec PrecompiledDefaultBinaryMessenger_606240726_send_3244 + 212 14 App 0x000000010583b10c Precompiled_MethodChannelinvokeMethod_618480135async_op_3242 + 312 15 App 0x000000010583afac Precompiled_MethodChannel__invokeMethod_618480135_3241 + 424 16 App 0x000000010593c3c4 Precompiled_MethodChannel_invokeMethod_7366 + 128 17 App 0x0000000105b16fac Precompiled_MethodChannelFlutterSoundPlayer_invokeMethodasync_op_15679 + 360 18 App 0x0000000105b16e1c Precompiled_MethodChannelFlutterSoundPlayer_invokeMethod_15678 + 320 19 App 0x0000000105b1753c Precompiled_MethodChannelFlutterSoundPlayer_setSubscriptionDuration_15684 + 172 20 App 0x0000000105b1e860 Precompiled_FlutterSoundPlayer_setSubscriptionDurationasync_op_15765 + 420 21 App 0x00000001057ba7b8 Precompiled___rootRunUnary_4048458954 + 104 22 App 0x00000001057ba738 PrecompiledrootRunUnary_4048458rootRunUnary_4048458_953 + 132 23 App 0x0000000105c9463c PrecompiledCustomZone_4048458_runUnary_21231 + 172 24 App 0x0000000105792174 PrecompiledFutureListener_4048458_handleValue_281 + 208 25 App 0x00000001057bb9cc Precompiled__Future_4048458propagateToListeners_4048458_handleValueCallback_983 + 52 26 App 0x000000010578b384 PrecompiledFuture_4048458propagateToListeners_4048458_191 + 1140 27 App 0x000000010579269c PrecompiledFuture_4048458completeWithValue_4048458_291 + 124 28 App 0x00000001057bc1a0 PrecompiledFuture_4048458__asyncCompleteWithValue_4048458anonymous_closure992 + 44 29 App 0x00000001057927fc Precompiled___rootRun_4048458294 + 200 30 App 0x00000001057928f0 PrecompiledrootRun_4048458rootRun_4048458_295 + 124 31 App 0x0000000105c944ac PrecompiledCustomZone_4048458_run_21229 + 160 32 App 0x0000000105c964e4 PrecompiledCustomZone_4048458_runGuarded_21271 + 52 33 App 0x0000000105c94e64 PrecompiledCustomZone_4048458_bindCallbackGuardedanonymous_closure21242 + 44 34 App 0x0000000105792cb0 Precompiled_microtaskLoop_4048458304 + 120 35 App 0x0000000105792b94 PrecompiledstartMicrotaskLoop_4048458_303 + 40 36 App 0x0000000105792b58 Precompiled___startMicrotaskLoop_4048458startMicrotaskLoop_4048458_302 + 24 37 App 0x0000000105786110 Precompiled_Stub_InvokeDartCode + 264 38 Flutter 0x00000001030785e8 0x102b34000 + 5522920 39 Flutter 0x0000000103079180 0x102b34000 + 5525888 40 Flutter 0x000000010317549c 0x102b34000 + 6558876 41 Flutter 0x0000000102f069e0 0x102b34000 + 4008416 42 Flutter 0x0000000102e1e114 0x102b34000 + 3055892 43 Flutter 0x0000000102e2150c 0x102b34000 + 3069196 44 CoreFoundation 0x000000018055a3d0 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28 (CFRunLoop.c:1807) 45 CoreFoundation 0x0000000180559fd4 CFRunLoopDoTimer + 1004 (CFRunLoop.c:2415) 46 CoreFoundation 0x00000001805594b4 CFRunLoopDoTimers + 324 (CFRunLoop.c:2575) 47 CoreFoundation 0x0000000180553840 __CFRunLoopRun + 1912 (CFRunLoop.c:3090) 48 CoreFoundation 0x0000000180552b90 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242) 49 Flutter 0x0000000102e213d8 0x102b34000 + 3068888 50 Flutter 0x0000000102e20b98 0x102b34000 + 3066776 51 libsystem_pthread.dylib 0x00000001c6c38b3c _pthread_start + 288 (pthread.c:881) 52 libsystem_pthread.dylib 0x00000001c6c3d880 thread_start + 8


jcblancomartinez commented 2 years ago

Hi @Larpoux ,

This is affecting my users in Prod. Could you please take a quick look? Let me know if I can do anything to help.

Regards.

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.