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

[iOS] Crash in Release mode only #793

Closed
mrigo opened this issue Nov 25, 2019 · 7 comments
Closed

[iOS] Crash in Release mode only #793

mrigo opened this issue Nov 25, 2019 · 7 comments

Comments

@mrigo
Copy link

mrigo commented Nov 25, 2019

Configuration

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Memory: 62.39 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.11.4 - /usr/local/bin/node
    npm: 5.6.0 - /usr/local/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 19, 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.3, 29.0.2
      System Images: android-19 | Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.5 => 0.60.5 
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

What react-native-track-player version are you using?
2.0.0-rc13

Issue

Only on iOS in release mode, the app crashes with this error after adding the tracks (I think, I can't debug clearly in release mode so I can't find the exact point where the app crashes):

2019-11-25 16:04:05.776 [info][tid:main][RNGestureHandlerManager.m:135] [GESTURE HANDLER] Initialize gesture handler for root view <RCTRootContentView: 0x7f8bd03012b0; reactTag: 1; frame = (0 0; 0 0); gestureRecognizers = <NSArray: 0x6000008e5aa0>; layer = <CALayer: 0x6000006d8420>>
2019-11-25 16:04:05.778467+0100 MyFaba[9595:892185] [GESTURE HANDLER] Initialize gesture handler for root view <RCTRootContentView: 0x7f8bd03012b0; reactTag: 1; frame = (0 0; 0 0); gestureRecognizers = <NSArray: 0x6000008e5aa0>; layer = <CALayer: 0x6000006d8420>>
Resetting player.
2019-11-25 16:04:09.022832+0100 MyFaba[9595:892364] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000665000> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Adding tracks: [<react_native_track_player.Track: 0x7f8bcdc84d90>, <react_native_track_player.Track: 0x7f8bcdd07c40>, <react_native_track_player.Track: 0x7f8bcdd09490>, <react_native_track_player.Track: 0x7f8bcdc84ea0>, <react_native_track_player.Track: 0x7f8bcdd7c3b0>, <react_native_track_player.Track: 0x7f8bd031ee70>]
2019-11-25 16:04:09.119280+0100 MyFaba[9595:892596] -[__NSDictionaryM length]: unrecognized selector sent to instance 0x600000663ee0
2019-11-25 16:04:09.125431+0100 MyFaba[9595:892596] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM length]: unrecognized selector sent to instance 0x600000663ee0'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000108dfd02e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x0000000107dcab20 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000108e1df94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x0000000108e01dac ___forwarding___ + 1436
	4   CoreFoundation                      0x0000000108e03f38 _CF_forwarding_prep_0 + 120
	5   CFNetwork                           0x000000010868d877 _CFHTTPServerResponseEnqueue + 42815
	6   CFNetwork                           0x0000000108584dd1 _CFStreamErrorFromCFError + 7283
	7   CFNetwork                           0x000000010851a2e8 CFURLRequestSetHTTPHeaderFieldValue + 114
	8   CoreFoundation                      0x0000000108e5eb51 -[__NSDictionaryM __apply:context:] + 113
	9   MediaToolbox                        0x000000010f650b8c figHttpRequestSetupNSURLSessionTask + 399
	10  MediaToolbox                        0x000000010f650849 _FigHTTPRequestCreateWithNSURLSession + 3174
	11  MediaToolbox                        0x000000010f682a03 figHTTPRequestSessionNSCreateHTTPRequest + 199
	12  MediaToolbox                        0x000000010f5bdc7c FigCFHTTPCreateOpenRequest + 418
	13  MediaToolbox                        0x000000010f5bda62 FigCFHTTPOpen + 79
	14  MediaToolbox                        0x000000010f6b25b7 fbfs_CreateFlumeAsync + 1004
	15  MediaToolbox                        0x000000010f6b1b97 FigByteStreamFactoryCreateStreamFromURLWithOptionsAsync + 2302
	16  MediaToolbox                        0x000000010f6b1082 FigByteStreamFactoryCreateStreamFromURLWithOptions + 245
	17  MediaToolbox                        0x000000010f7a66d1 EnsureContentStreamCreated + 2251
	18  MediaToolbox                        0x000000010f79cc20 EnsureAssetTypeEstablished + 74
	19  MediaToolbox                        0x000000010f79ca83 URLAssetPropertyWorkFunction + 573
	20  libdispatch.dylib                   0x000000010d9e3d48 _dispatch_client_callout + 8
	21  libdispatch.dylib                   0x000000010d9ea5ef _dispatch_lane_serial_drain + 788
	22  libdispatch.dylib                   0x000000010d9eb1b5 _dispatch_lane_invoke + 476
	23  libdispatch.dylib                   0x000000010d9f528c _dispatch_root_queue_drain + 351
	24  libdispatch.dylib                   0x000000010d9f507f _dispatch_worker_thread + 278
	25  libsystem_pthread.dylib             0x00007fff51bfe2eb _pthread_body + 126
	26  libsystem_pthread.dylib             0x00007fff51c01249 _pthread_start + 66
	27  libsystem_pthread.dylib             0x00007fff51bfd40d thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Code

setupTracks = async (chapters) => {

        this.setupPlayer(chapters, async (chapters) => {
            if (chapters.length == 0)
                return;

            var headerValue = await getCheckHeaderValue();
            var token = await retrieveToken();

            var tracks = chapters.map((chapter, index) => {

                return {
                    id: `id_${index}`,
                    url: `${chapter.audioUrl}`,
                    title: `${chapter.title}`,
                    artist: `${chapter.character}`,
                    album: `${chapter.collection}`,
                    artwork: `${chapter.image}`,
                    headers: {
                        "X-Auth": headerValue,
                        "Authorization": `Bearer ${token}`,
                        "Accept":"*\/*",
                        "Range":"bytes=0-1",
                        "X-Platform": Platform.OS,
                    }
                }
            });

            if (tracks.length == chapters.length) {
                console.log(tracks);
                TrackPlayer.add(tracks).then( async () => {
                    console.log("Tracks added!!!");
                }).catch( error => {
                    console.log(error);
                });
            } else {
                console.log("Error loading tracks!");
            }
        });                
    }


setupPlayer = (chapters, callback) => {
        try {
            TrackPlayer.reset();
            TrackPlayer.setupPlayer().then(() => {
                TrackPlayer.updateOptions({
                    stopWithApp: true,
                    capabilities: [
                        Capability.Play,
                        Capability.Pause,
                        Capability.Stop,
                        Capability.SkipToNext,
                        Capability.SkipToPrevious,
                    ],
                    compactCapabilities: [
                        Capability.Play,
                        Capability.Pause,
                    ],
                });
                if (callback) {
                    callback(chapters);    
                }
            });
        } catch (error) {
            console.log("error audio service");
            console.log(error);
        }
        
    }
@mrigo
Copy link
Author

mrigo commented Nov 28, 2019

Any update on this? Is it even happening to anyone?

@maxckelly
Copy link

maxckelly commented Sep 19, 2020

@mrigo - I'm getting a similar crash. It's occurring around the Track.init. See logs below. Doesn't actually occur with all user just a minority.

Did you manage to find a solution for this?

Thread 7 name:
Thread 7 Crashed:
0   A Life Lived                  	0x000000010315492c MediaURL.init(object:) + 1512 (MediaURL.swift:28)
1   A Life Lived                  	0x0000000103154794 MediaURL.init(object:) + 1104 (MediaURL.swift:28)
2   A Life Lived                  	0x000000010316d65c Track.init(dictionary:) + 668 (Track.swift:38)
3   A Life Lived                  	0x0000000103162038 Track.__allocating_init(dictionary:) + 8 (<compiler-generated>:0)
4   A Life Lived                  	0x0000000103162038 RNTrackPlayer.add(trackDicts:before:resolve:reject:) + 688
5   A Life Lived                  	0x0000000103162038 0x102f4c000 + 2187320 (RNTrackPlayer.swift:290)
6   A Life Lived                  	0x0000000103162be0 @objc RNTrackPlayer.add(trackDicts:before:resolve:reject:) + 220 (<compiler-generated>:0)
7   CoreFoundation                	0x00000001ad5235d4 __invoking___ + 148
8   CoreFoundation                	0x00000001ad3fe9e8 -[NSInvocation invoke] + 448 (NSForwarding.m:3389)
9   CoreFoundation                	0x00000001ad3fefa4 -[NSInvocation invokeWithTarget:] + 80 (NSForwarding.m:3495)
10  A Life Lived                  	0x0000000103057670 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 460 (RCTModuleMethod.mm:569)
11  A Life Lived                  	0x000000010305975c facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) + 244 (RCTNativeModule.mm:108)
12  A Life Lived                  	0x00000001030594c0 facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const + 44 (RCTNativeModule.mm:73)
13  A Life Lived                  	0x00000001030594c0 invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 88 (RCTNativeModule.mm:65)
14  libdispatch.dylib             	0x00000001ad11afd0 _dispatch_call_block_and_release + 32 (init.c:1454)
15  libdispatch.dylib             	0x00000001ad11cac8 _dispatch_client_callout + 20 (object.m:559)
16  libdispatch.dylib             	0x00000001ad123c08 _dispatch_lane_serial_drain + 580 (inline_internal.h:2548)
17  libdispatch.dylib             	0x00000001ad124734 _dispatch_lane_invoke + 408 (queue.c:3862)
18  libdispatch.dylib             	0x00000001ad12e528 _dispatch_workloop_worker_thread + 708 (queue.c:6590)
19  libsystem_pthread.dylib       	0x00000001f4a70908 _pthread_wqthread + 276 (pthread.c:2193)
20  libsystem_pthread.dylib       	0x00000001f4a7777c start_wqthread + 8

@fernandopascoalbr
Copy link

Some problem here

@maxckelly
Copy link

maxckelly commented Nov 21, 2020

Unsure if this might help anyone but I found my issue. While I didn't find a 'real' solution for it I was able to prevent the crash.

It was to do with Codepush each time the user would close the app or put it in background and then reopen it code push would look for an update and if there is one it would update the client. For some reason this was causing Track player to crash. I didn't look into it further just removed the update off code push. Hope this helps someone.

@fernandopascoalbr
Copy link

@maxckelly thanks, but i'm not using codepush.
@mrigo how to solve this problem?

Example,I have two streams url:
one [works fine] = https://medias.sgr.globo.com/hls/aCBNSP/aCBNSP.m3u8

two [don't work] = https://23742406-channel-hls.ums.ustream.tv/playlist/directhls/channel/23742406/playlist.m3u8?sgn=0bb40779753db5b2e005ce78c261ba67cb554368

@fernandopascoalbr
Copy link

fernandopascoalbr commented Dec 1, 2020

@mrigo my problem is solved after change param awaitForBuffer to true into IOS.

@dcvz dcvz closed this as completed Aug 10, 2021
@srahul9134
Copy link

srahul9134 commented Nov 6, 2021

Can anyone tell where to use awaitForBuffer ?

AddInstanceForFactory: No factory registered for id <CFUUID 0x600001d08c60> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Adding tracks: [<react_native_track_player.Track: 0x7fae3ef2aa30>]

also getting this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants