Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Crash Running on RN0.34 and real device #146

Closed
cbcye opened this issue Oct 4, 2016 · 5 comments
Closed

Crash Running on RN0.34 and real device #146

cbcye opened this issue Oct 4, 2016 · 5 comments

Comments

@cbcye
Copy link

cbcye commented Oct 4, 2016

The application is working on iOS simulator but when i running on iphone 5s occus the following error:

invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2016-10-04 12:29:05.896002 Huola[2722:1095583] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

@wkh237
Copy link
Owner

wkh237 commented Oct 4, 2016

@cbcye , thanks for reporting this issue. Would you mind provide some more information about the iOS version and how you use the library when this error occurs ? It'd be great if you there's some code snippet or even a sample project 😄

@cbcye
Copy link
Author

cbcye commented Oct 4, 2016

@wkh237 Thanks, my environment is : RN 0.34+react-native-fetch-blob 0.9.6+iOS 10.0.2 on iPhone 5S device,

The last step is line 140 in RNFetchBlobNetwork.m file, like below:

image

after that i get the error like the first post on above, my app crash.

Application code like below, the code has been comments is help to debug , may be there have the other reason occurs this problem. this code is * working in a New and Empty project*. but it is failure on my real project

let dirs = RNFetchBlob.fs.dirs
         alert('image dirs: ' + dirs.DocumentDir);
        // send http request in a new thread (using native code)
        RNFetchBlob
            .config({
                path: dirs.DocumentDir + '/' + rand(20) + '.png'
            })
            .fetch('GET', url)
            // when response status code is 200
            .then((res) => {
                // let imgPath = res.path();
                // alert('image path: ' + imgPath);
                // this.setState({
                //     localImagePath: imgPath,
                //     imageLoaded: true,
                // });

            })
            // Status code is not 200
            .catch((errorMessage, statusCode) => {
                // error handling
                alert(errorMessage);
            })

@wkh237
Copy link
Owner

wkh237 commented Oct 4, 2016

@cbcye , thanks for the information 👍 Could you remove lines 139,140,287,522 in RNFetchBlobNetowkr.m and try if it works ? Thank you !

@cbcye
Copy link
Author

cbcye commented Oct 4, 2016

@wkh237 Thanks very much for your help !!! I spend near three days to resolve this issue( i use the react-native-fs module before and it is also this problem). I find the real reason is my url has include Chinese words and it not been encode. the url like below,:
http://xxx.com/?n=中国

before your suggest it doesn't throw the useful error message just crash. but follow your modify suggest it throw the message tell me the URL formate is incorrect. then i find the real reason!!!

Finally, I use the encodeURI to encode Chinese words and just use the original react-native-fetch-blob code. it is working now.

Thanks again!!!

@wkh237
Copy link
Owner

wkh237 commented Oct 5, 2016

@cbcye , great to know the problem got solved 👍 The information is really helpful, I've spotted this problem befroe, but finally decided not changing the url implicitly as a result the library will not automatically URL encoding unicode characters.

However, I think it'd be better to notice developers about this in the document 😄

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

No branches or pull requests

2 participants