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 on initialization. Can't get it to run at all. C++ “basic_string(const char*) detected nullptr” runtime error. #2431

Open
richardshaw700 opened this issue Feb 7, 2025 · 3 comments
Labels

Comments

@richardshaw700
Copy link

Describe the Bug
C++ “basic_string(const char*) detected nullptr” runtime error.
Image:

Steps To Reproduce
Try installing the library and running it with basic initialization on iOS react native

Code To Reproduce
Add
import TrackPlayer from 'react-native-track-player';
to your index.js

Replicable on Example App?
no

Environment Info:
System:
OS: macOS 15.2
CPU: (8) arm64 Apple M2
Memory: 217.02 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.15.0
path: /usr/local/bin/node
Yarn: Not Found
npm:
version: 10.7.0
path: /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.15.2
path: /Users/richardshaw/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 3.3.0
path: /Users/richardshaw/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.77.0
wanted: 0.77.0
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true

"react-native-track-player": "^4.1.1",

Real device

Sequoia 15.2
iOS 18.3

https://i.ibb.co/kgm6Qqd4/player-crash.png

@richardshaw700
Copy link
Author

Found this:

Which comes from this:

RCT_EXTERN_METHOD(setupPlayer:(NSDictionary *)data
                  resolver:(RCTPromiseResolveBlock)resolve
                  rejecter:(RCTPromiseRejectBlock)reject);

That Objective‐C in RNTrackPlayerBridge.m is the “bridge” layer for react-native-track-player—and it looks correct in the old (non‐TurboModule) architecture. But in the new TurboModule system, sometimes a RCT_EXTERN_METHOD or even a RCT_EXTERN_REMAP_MODULE can wind up producing an empty jsName, especially if the library hasn’t been fully updated for the new architecture.

Essentially, the debugging confirms that the bridging code for setupPlayer is being found, but its jsName is coming through as an empty string. That leads to std::string("") → std::string(nullptr) in the TurboModule layer.

Why This Happens

RCT_EXTERN_REMAP_MODULE(TrackPlayerModule, RNTrackPlayer, NSObject) only sets the module name (“TrackPlayerModule”) when bridging from Swift/ObjC to JavaScript. Meanwhile, RCT_EXTERN_METHOD picks up an Objective‐C method signature but does not always set a separate JavaScript method name if you don’t explicitly specify one in a “remap” macro.

Under the old architecture, that might be enough for RCTBridgeModule to generate an exported method name (like “setupPlayer”). Under the new architecture (with TurboModules), though, the bridging logic is more strict. If it doesn’t see a RCT_REMAP_METHOD(Original, JSName, ...) or some such, it can wind up with an empty or null jsName internally.

Next steps

Long term:
fix bridging for TurboModules in new architecture

Short term:
Try adding a more explicit JS name with a RCT_EXTERN_REMAP_METHOD or RCT_REMAP_METHOD.
disable new architecture

@Andrija00
Copy link

I am having same issue this needs to be fixed ASAP

@diptimaya-seneca
Copy link

Need a urgent fix with new architechture in RN 0.77. Thanks

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

3 participants