question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS Native Crash when uploading blobs using aws-sdk

See original GitHub issue

When using the aws-sdk package on iOS to upload files to S3, iOS experiences a native crash. I have narrowed it down to this line here: https://github.com/facebook/react-native/blob/v0.61.5/Libraries/Blob/RCTBlobManager.mm#L101. If I comment out that line, then the upload works fine. I am not an iOS expert, so I am not sure what it is doing. Maybe the original author can comment: @satya164

React Native version: 0.61.5

Error

Exception ‘*** -[NSConcreteMutableData subdataWithRange:]: range {0, 1769328} exceeds data length 458’ was thrown while invoking sendRequest on target Networking with params ( { data = { blob = { “__collector” = { }; blobId = “11f8ea23-de9a-4a08-ad4d-c4181df42883”; offset = 0; size = 1769328; }; trackingName = unknown; }; headers = { authorization = “AWS4-HMAC-SHA256 Credential=ASIA6QAAAAAHOZSVFSMH/20200123/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-meta-document-type;x-amz-meta-file-id;x-amz-meta-file-name;x-amz-meta-person-id;x-amz-security-token;x-amz-user-agent, Signature=cee1e24a313d918991150c4e9864ef8cea2f0756cd148b83307155006755d45a”; “content-type” = “application/octet-stream”; “x-amz-content-sha256” = “UNSIGNED-PAYLOAD”; “x-amz-date” = 20200123T195414Z; “x-amz-security-token” = “FwoGZXIvYXdzEMX…QcPwuX645EoVpgYfWkcuu63fH2Eyjhc9/zJBBiDfR2xroIZawDJxj2g0ur2IRZbBlS0d7sjcOW3LbVQ+bbEIv9PuffwSLn87JVIFkKObzp/EFMi3k+pjO0XGMKyzbHQmOERlegrv7PvKiITp6K6uFJktcQ4oewkuMsaF2CzBQ9xQ=”; “x-amz-user-agent” = “aws-sdk-js-react-native/2.608.0 callback”; }; incrementalUpdates = 1; method = PUT; responseType = base64; timeout = 120000; url = “https://public-bucket.s3.amazonaws.com/my-upload-file.pdf”; withCredentials = 1; }, 7255 ) callstack: ( 0 CoreFoundation 0x000000010b19a27e _exceptionPreprocess + 350 1 libobjc.A.dylib 0x0000000109e38b20 objc_exception_throw + 48 2 Foundation 0x0000000107f8ce40 -[NSData(NSData) writeToFile:options:error:] + 0 3 MyApp 0x00000001066e5ae8 -[RCTBlobManager resolve:offset:size:] + 472 4 MyApp 0x00000001066e57c2 -[RCTBlobManager resolve:] + 706 5 MyApp 0x00000001066e8992 -[RCTBlobManager handleNetworkingRequest:] + 626 6 MyApp 0x0000000106701fa5 -[RCTNetworking processDataForHTTPQuery:callback:] + 1749 7 MyApp 0x0000000106700c35 -[RCTNetworking buildRequest:completionBlock:] + 3749 8 MyApp 0x0000000106707e4d -[RCTNetworking sendRequest:responseSender:] + 253 9 CoreFoundation 0x000000010b1a120c invoking + 140 10 CoreFoundation 0x000000010b19e3af -[NSInvocation invoke] + 319 11 CoreFoundation 0x000000010b19e684 -[NSInvocation invokeWithTarget:] + 68 12 MyApp 0x0000000106612c12 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2658 13 MyApp 0x0000000106616d47 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 791 14 MyApp 0x0000000106616853 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 131 15 MyApp 0x00000001066167c9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25 16 libdispatch.dylib 0x000000010e3bc848 _dispatch_call_block_and_release + 12 17 libdispatch.dylib 0x000000010e3bd7b9 _dispatch_client_callout + 8 18 libdispatch.dylib 0x000000010e3c3526 _dispatch_lane_serial_drain + 707 19 libdispatch.dylib 0x000000010e3c3f5c _dispatch_lane_invoke + 388 20 libdispatch.dylib 0x000000010e3cdff9 _dispatch_workloop_worker_thread + 626 21 libsystem_pthread.dylib 0x00007fff524636fc _pthread_wqthread + 290 22 libsystem_pthread.dylib 0x00007fff52462827 start_wqthread + 15 )

RCTFatal facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int):😒_0::operator()() const invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) _dispatch_call_block_and_release _dispatch_client_callout _dispatch_lane_serial_drain _dispatch_lane_invoke _dispatch_workloop_worker_thread _pthread_wqthread start_wqthread

Steps To Reproduce

  1. I have created an Expo snack with a repro case: https://snack.expo.io/@chris-feist/document-upload-issue-demo
  2. Select file and upload it using the aws-sdk and S3 client.
  3. Note that it does not repro when the device/emulator is connected to the RN debugger

Describe what you expected to happen: I expect the upload to work (as it does on android).

Snack, code example, screenshot, or link to a repository: https://snack.expo.io/@chris-feist/document-upload-issue-demo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:17

github_iconTop GitHub Comments

4reactions
maneeshtcommented, Nov 4, 2022

It seems like there are multiple problems here, as applying the fix from https://github.com/facebook/react-native/pull/31392 doesn’t quite work for me. As mentioned here, there seems to be a race condition between adding to the blob and sending it out.

3reactions
dlbearscommented, Apr 6, 2021

Same issue (particularly noticeable on older ios devices when using large files, 6S)

Read more comments on GitHub >

github_iconTop Results From Across the Web

IOS (React-native) app crashes in … | Apple Developer Forums
Hi, I am stuck on this for a few days now. Please help. My ReactNative app crashes in TestFlight but seems to work...
Read more >
React Native Error Creating Blobs via XMLHttpRequest
I am working on a React-Native app where photos and documents are one of the main features needed. Users are constantly taking pictures...
Read more >
App Center Crashes for React Native - Microsoft Learn
In order for your Crash.setListener methods to work as expected you need to check if your application configured properly. Open the project's ...
Read more >
Resolve issues with uploading large files in Amazon S3
Note: If you use the Amazon S3 console, the maximum file size for uploads is 160 GB. To upload a file that is...
Read more >
Using the AWS Mobile SDKs for iOS and Android
Develop applications with the AWS Mobile SDKs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found