Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in MediaURL.swift initialization on iOS #2384

Open
enestatli opened this issue Oct 16, 2024 · 0 comments
Open

Crash in MediaURL.swift initialization on iOS #2384

enestatli opened this issue Oct 16, 2024 · 0 comments
Labels

Comments

@enestatli
Copy link

Describe the Bug
The iOS app is experiencing intermittent crashes related to the module. The crash occurs during the initialization of a MediaURL object in the MediaURL.swift file, specifically when setting the queue for playback.

Steps To Reproduce
The crash is intermittent and not consistently reproducible. It occurs when setting the queue for playback using the setQueue method.

Code To Reproduce
Here's the relevant code that might be triggering the crash:

async setQueue(tracks: Prediction[]) {
    const convertedTracks = this.convertTracks(tracks);
    if (convertedTracks.length > 0) {
        await TrackPlayer.setQueue(convertedTracks);
    }
}

convertTrack(track: Prediction) {
    if (track.audio_url) {
        return {
            ...track,
            url: track.audio_url,
            artwork: track.image_url,
            artist: track.tags || 'artist',
        };
    }
    return null;
}

convertTracks(tracks: Prediction[]) {
    const convertedTracks = [];
    for (const track of tracks) {
        const convertedTrack = this.convertTrack(track);
        if (convertedTrack) {
            convertedTracks.push(convertedTrack);
        }
    }
    return convertedTracks;
}

Replicable on Example App?
I have not attempted to replicate this bug in the React Native Track Player Example App.

Environment Info:

  OS: macOS 14.5
  CPU: (8) arm64 Apple M2
  Memory: 90.61 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.0
    path: ~/.nvm/versions/node/v18.17.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.6.7
    path: ~/.nvm/versions/node/v18.17.0/bin/npm
  Watchman:
    version: 2024.04.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/enestatli/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "29"
      - "30"
      - "31"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-30 | Google APIs Intel x86 Atom
      - android-30 | Google Play ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10406996
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/enestatli/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.7
    wanted: 0.73.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

How I can Help
I can provide more detailed crash logs and any additional context that might be helpful. I'm open to testing potential fixes or gathering more information as needed.

While I haven't investigated the underlying Swift code causing this bug, here's the relevant part of the crash log that might be useful:

image
Crashed: com.facebook.react.TrackPlayerModuleQueue
SIGABRT ABORT 0x00000001fe7ab198
          Crashed: com.facebook.react.TrackPlayerModuleQueue
0  libsystem_kernel.dylib         0x7198 __pthread_kill + 8
1  libsystem_pthread.dylib        0xd5f8 pthread_kill + 208
2  libsystem_c.dylib              0x1c4b8 abort + 124
3  libswiftCore.dylib             0x2f2998 swift::fatalError(unsigned int, char const*, ...) + 130
4  libswiftCore.dylib             0x2f29b4 swift::warningv(unsigned int, char const*, char*) + 26
5  libswiftCore.dylib             0x2ea6ec swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 74
6  libswiftCore.dylib             0x2ea764 swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) + 118
7  libswiftCore.dylib             0x2ee6ac swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 278
8  Zona                           0x95f840 MediaURL.init(object:) + 32 (MediaURL.swift:32)
9  Zona                           0x97066c Track.updateMetadata(dictionary:) + 60 (Track.swift:60)
10 Zona                           0x970100 Track.init(dictionary:) + 42 (Track.swift:42)
11 Zona                           0x96a374 RNTrackPlayer.setQueue(trackDicts:resolve:reject:) + 661 (RNTrackPlayer.swift:661)
12 Zona                           0x96a6c8 @objc RNTrackPlayer.setQueue(trackDicts:resolve:reject:) + 77200 (<compiler-generated>:77200)
13 CoreFoundation                 0x6df40 __invoking___ + 144
14 CoreFoundation                 0x1f1c8 -[NSInvocation invoke] + 276
15 CoreFoundation                 0x1ed68 -[NSInvocation invokeWithTarget:] + 60
16 Zona                           0x43b6b8 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 587 (RCTModuleMethod.mm:587)
17 Zona                           0x43d7e4 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 196 (RCTNativeModule.mm:196)
18 Zona                           0x43d430 invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 298 (optional:298)
19 libdispatch.dylib              0x637a8 _dispatch_call_block_and_release + 24
20 libdispatch.dylib              0x64780 _dispatch_client_callout + 16
21 libdispatch.dylib              0x3f6fc _dispatch_lane_serial_drain$VARIANT$armv81 + 600
22 libdispatch.dylib              0x401b0 _dispatch_lane_invoke$VARIANT$armv81 + 380
23 libdispatch.dylib              0x49f14 _dispatch_workloop_worker_thread + 608
24 libsystem_pthread.dylib        0x1bd0 _pthread_wqthread + 284
25 libsystem_pthread.dylib        0x1720 start_wqthread + 8

The crash seems to be happening in the MediaURL.init(object:) method, specifically on line 32 of MediaURL.swift. It appears to be related to force unwrapping of optionals or incorrect type casting.

I'm not able to create a Pull Request with a fix at this time, but I'm willing to test any proposed solutions or provide any additional information that might be helpful in resolving this issue.

@enestatli enestatli added the Bug label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant