AnonymHK / betterplayer

Bug fix version for betterplayer
Apache License 2.0
42 stars 32 forks source link

[BUG] Random crash on iOS #5

Closed blendicavlad closed 1 year ago

blendicavlad commented 1 year ago

History check I confirm that i couldn't find a similar problem in the issue history.

Describe the bug Opening the video player crashed the app. The bug happened only once, on a real device. I couldn't reproduce the bug anymore. I only have the Firebase Crashalytics log at the time of the crash:

Crashed: com.apple.NSURLSession-delegate
0  libswiftCore.dylib             0x3dcd08 swift_isUniquelyReferenced_nonNull_native + 38
1  better_player                  0x15b60 $sSlsE3mapySayqd__Gqd__7ElementQzKXEKlFShySo29AVAssetResourceLoadingRequestCG_AFSgTg5039$s13better_player17CachingPlayerItemC22d46LoaderDelegateC22processPendingRequestsyyFSo07c3F14eF11CSgAHXEfU0_13better_player0ijK0C0dmN0CTf1cn_nTf4ng_n + 444
2  better_player                  0x16034 $s13better_player17CachingPlayerItemC22ResourceLoaderDelegateC10urlSession_8dataTask10didReceiveySo12NSURLSessionC_So0o4DataL0C10Foundation0P0VtFTf4dnnn_n + 232
3  better_player                  0x11958 $s13better_player17CachingPlayerItemC22ResourceLoaderDelegateC10urlSession_8dataTask10didReceiveySo12NSURLSessionC_So0o4DataL0C10Foundation0P0VtFTo + 120
4  FirebasePerformance            0x174bc __InstrumentURLSessionDataTaskDidReceiveData_block_invoke + 160
5  CFNetwork                      0x87c74 _CFHostIsDomainTopLevelForCertificatePolicy + 20824
6  libdispatch.dylib              0x1e6c _dispatch_call_block_and_release + 32
7  libdispatch.dylib              0x3a30 _dispatch_client_callout + 20
8  libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
9  libdispatch.dylib              0xbcb4 _dispatch_lane_invoke + 444
10 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
11 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
12 libsystem_pthread.dylib        0xe5c start_wqthread + 8

To Reproduce

  1. Open the the player. (My video had a .MOV exension, in case it could be relevant)

*Example code

void _initVideoPlayer(String url) {
    BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource(
      BetterPlayerDataSourceType.network,
      url,
      cacheConfiguration: BetterPlayerCacheConfiguration(
        useCache: true,
        maxCacheFileSize: 250 * 1024 * 1024,
        maxCacheSize: 4 * 1000 * 1024 * 1024,
        key: widget.firebaseVideoResourceURL,
      ),
    );
    _betterPlayerController = BetterPlayerController(
      BetterPlayerConfiguration(
        aspectRatio: 16 / 9,
        expandToFill: false,
        fullScreenAspectRatio: 16 / 9,
        fit: BoxFit.fitHeight,
        eventListener: (event) {
          setState(() {
            if (event.betterPlayerEventType ==
                BetterPlayerEventType.openFullscreen) {
              _betterPlayerController?.setControlsEnabled(true);
              if (widget.controllerEventEmitter != null) {
                widget.controllerEventEmitter?.isFullscreen = true;
              }
            }
            if (event.betterPlayerEventType ==
                BetterPlayerEventType.hideFullscreen) {
              _betterPlayerController?.setControlsEnabled(false);
              if (widget.controllerEventEmitter != null) {
                widget.controllerEventEmitter?.isFullscreen = false;
              }
            }
            if (event.betterPlayerEventType == BetterPlayerEventType.pause) {
              _playPauseBtn = Icon(
                Platform.isIOS
                    ? CupertinoIcons.play_arrow_solid
                    : Icons.play_arrow_outlined,
                color: AppColors.accentColor,
                size: 28,
              );
            }
            if (event.betterPlayerEventType == BetterPlayerEventType.play) {
              _playPauseBtn = Icon(
                Platform.isIOS
                    ? CupertinoIcons.pause_solid
                    : Icons.pause_outlined,
                color: AppColors.accentColor,
                size: 28,
              );
            }
          });
        },
        autoPlay: widget.autoplay,
        looping: true,
        // autoDetectFullscreenAspectRatio: true,
        deviceOrientationsAfterFullScreen: [
          DeviceOrientation.portraitUp,
        ],
        controlsConfiguration: const BetterPlayerControlsConfiguration(
          showControlsOnInitialize: false,
          controlBarColor: Colors.transparent,
          loadingColor: AppColors.accentColor,
          backgroundColor: Colors.transparent,
          progressBarPlayedColor: AppColors.accentColor,
          enableQualities: false,
          enableSubtitles: false,
          enableAudioTracks: false,
        ),
        showPlaceholderUntilPlay: widget.placeholder != null,
        placeholder: widget.placeholder
      ),
      betterPlayerDataSource: betterPlayerDataSource,
    );
    _betterPlayerController?.setControlsEnabled(false);
  }

Expected behavior The video player should not crash

Screenshots If applicable, add screenshots to help explain your problem.

Flutter doctor [✓] Flutter (Channel stable, 3.10.1, on macOS 13.1 22C65 darwin-arm64, locale en-RO) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.77.3) [✓] Connected device (4 available) [✓] Network resources

• No issues found!

Better Player version

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

AnonymHK commented 1 year ago

Sorry, based on the information you provided, it is difficult to determine where the problem occurred! Occasional faults can be captured using SentryFlutter and Bugly for error detection!

blendicavlad commented 1 year ago

Yep, I understand is a hard to track issue, this is the the entire stack I have on the error :(

Sorry, based on the information you provided, it is difficult to determine where the problem occurred! Occasional faults can be captured using SentryFlutter and Bugly for error detection!

AnonymHK commented 1 year ago

There is currently no better solution, please record it first and wait for more feedback!