Closed Cheranarasu closed 6 years ago
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
^ it looks like you're trying to access a non secure resource, e.g. http://
, and have not editing for Info.plist
to allow this.
Apple started to disallow this, by default, a few years back. Try this with an https://
URL to see if it solves your issue.
Hi @spouliot ,
I tried to download https://
URL only. Download properly works with CreateDownloadTask
and had problem when use CreateDownloadTaskAsync
only. I need to use async to achieve my scenario. Need to download three format file with single button click.
Regards, Cheran
That's weird because you should not be seeing the message you pasted.
Anyway the best way to solve this is to attach a self-contained test case to this issue so we're able to duplicate the same crash (just by running the test case and see if crash). There's a lot of moving pieces in networking code and duplicating results can often be hard (timing, servers, protocols...).
Hi @spouliot ,
Sorry for inconvenience.
I tried to download http://
only, it download properly if CreateDownloadTask
used and error occurs only if use CreateDownloadTaskAsync
process. I have used below link process for App Transport Security policy,
https://stackoverflow.com/questions/32631184/the-resource-could-not-be-loaded-because-the-app-transport-security-policy-requi
Please find sample Xamarin iOS project with single download which using both CreateDownloadTask
and CreateDownloadTaskAsync
. Initially, CreateDownloadTaskAsync
comment and download code placed in SimpleBackgroundTransferViewController.cs file.
http://files2.syncfusion.com/Downloads/BackgroundSample.zip
Please check it and give your valuable suggestion.
Hi @spouliot ,
I am struck on this for a week. Please give your valuable suggestion on this.
Regards, Cheran
Hi @spouliot ,
Is this Xamarin issue or not?. Please suggest any workaround for this if it is Xamarin issue or give any other suggestion to implement my process . I have already attached sample source in previous conversation itself. Please help me on this.
Regards, Cheran
@mandel-macaque can you please have a look at the attached sample ? thanks!
Hi @spouliot / @mandel-macaque ,
Could you please update any on this?
Regards, Cheran
@Cheranarasu looking at the issue, will get back to you with more information ASAP.
I have taken a look at the issue and the problem is not related to Xamarin but on how you are using the API. I have modified a little your code here to get you application to run and download several images asynchronously using the OS because you wanted to use a background session. The tasks are started in the background when Resume is called:
var urls = new string[] { ApoloDownloadUrlString, RulesDownloadUrlString, SampleDownloadUrlString, XamarinDownloadUrlString };
foreach(var u in urls) {
using(var url = NSUrl.FromString(u)) {
var t = session.CreateDownloadTask(url);
t.Resume();
}
}
So there is no need to use a ThredPool, await or any of the .net constructs. Something similar can be achieved with the Async methods, but those will be controlled by the app and will not use a background session.
Thanks for your update. I thought you may misunderstood my concept. I have to download three file in a single click with background process too and maintain a three file download progress into single progress bar (Put calculation to progress by receiving byte divided by total byte of three file). If we do like above, download couldn't wait for another and also one file completed then download completed event triggers. Because of this only, try to use CreateDownloadTaskAsync
and await to wait once download is going it stays and once download completed then triggers another download.
I have achieved this byDownloadFileTaskAsync
process using WebClient
. When unclock iOS device or minimize application download doesn't carry out. To achieve this only came for NSURLSession
, if use CreateDownloadTaskAsync
then application stopped. I have pasted console output in it.
WebClient Code Snippet:
WebClient m_webClient = new WebClient();
await m_webClient.DownloadFileTaskAsync(new Uri(downloadURL.PdfDownloadUrl), pdfFileName);
Also three file downloaded source updated in it. Please find source below and check it. http://files2.syncfusion.com/Downloads/BackgroundSample1.zip
2018-02-21 14:27:10.905 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: IDE Port: 10000 Transport: USB
Launched application 'com.syncfusion.BackgroundSession' on 'Syncpad-14473' with pid 323
2018-02-21 14:27:10.981 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 4
2018-02-21 14:27:10.982 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Processing: 'start debugger: sdb'
2018-02-21 14:27:10.983 SimpleBackgroundTransfer[323:47040] Xamarin.iOS: Debugger loaded with custom transport (fd: 4)
2018-02-21 14:27:10.983 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 5
2018-02-21 14:27:10.983 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Processing: 'connect output'
2018-02-21 14:27:10.984 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 6
2018-02-21 14:27:10.984 SimpleBackgroundTransfer[323:47059] Xamarin.iOS: Processing: 'start profiler: no'
2018-02-21 14:27:10.985 SimpleBackgroundTransfer[323:47040] Xamarin.iOS: Profiler not loaded (disabled)
Loaded assembly: /private/var/containers/Bundle/Application/B02E5BCB-2E0D-495E-9B49-29163E76A151/SimpleBackgroundTransfer.app/Xamarin.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/B02E5BCB-2E0D-495E-9B49-29163E76A151/SimpleBackgroundTransfer.app/System.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/B02E5BCB-2E0D-495E-9B49-29163E76A151/SimpleBackgroundTransfer.app/SimpleBackgroundTransfer.exe
Thread started: #2
2018-02-21 14:27:11.354 SimpleBackgroundTransfer[323:47040] OnActivated
2018-02-21 14:27:11.374 SimpleBackgroundTransfer[323:47040] InitBackgroundSession
Resolved pending breakpoint at 'SimpleBackgroundTransferViewController.cs:209,1' to void SimpleBackgroundTransfer.UrlSessionDelegate.DidFinishEventsForBackgroundSession (Foundation.NSUrlSession session) [0x00001].
Thread started:
Please let me know if further details needed.
Regards, Cheran
Hi @mandel-macaque ,
I have updated comment on this. Could you please reopen this issue and check it?. Please ping sample for CreateDownloadTaskAsync
process and this will help me to process in my scenario.
Regards, Cheran
@Cheranarasu I am not reopening the bug because there is no issue in the platform. The problem you have is that you are not an expert with the API and due to that you are getting a crash. This is not the right channel to request help with this kind of issues, I recommend the following:
Nevertheless, here you have a sample code that will do the following:
The requests are done in parallel and the progress bar will be updated correctly. If you want to perform the downloads one after the other, you have to add logic so that,
Again, please do not use github issues to request support when you have issues understanding the API and use the forums or stack overflow for that kind of questions, this channel is just for bug reports which is not this case.
I also have this problem, also download PDF files. I used the SDK of other companies that bind the Objective-C API. This problem caused the program to crash in the download PDF method, but the development on xcode native did not crash.
// -(void)signFileWithFileId:(NSString *)fileId hash:(NSString *)hash hasTsa:(NSString *)hasTsa completion:(void (^)(NSData *))completion failure:(void (^)(NSError *))failure;
[Export("signFileWithFileId:hash:hasTsa:completion:failure:")]
void SignFileWithFileId(string fileId, string hash, string hasTsa, Action<NSData> completion, Action<NSError> failure);
SZCAAuthSDK authSDK = SZCAAuthSDK.SZCAAuthShared();
string fileID = "201811021136203620719544";
string fileHash = "sA/rNtPP7KbQoPlps+iulyf5SQM=";
string hasTsa = "0";
//download PDF method
authSDK.SignFileWithFileId(fileID, fileHash, hasTsa, (NSData obj) => {
System.Diagnostics.Debug.WriteLine("SignFileWithFileId = " + obj);
}, (NSError obj) => {
System.Diagnostics.Debug.WriteLine("NSError = " + obj);
});
Thread 10 name: tid_db73 Dispatch queue: NSOperationQueue 0x280634560 (QOS: UNSPECIFIED)
Thread 10 Crashed:
0 libsystem_kernel.dylib 0x00000001b6e6f104 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001b6eee998 pthread_kill$VARIANT$armv81 + 296
2 libsystem_c.dylib 0x00000001b6dc6d78 abort + 140
3 SZCAAuth_Xamarin 0x0000000102cbe944 xamarin_printf + 5679428 (runtime.m:2458)
4 SZCAAuth_Xamarin 0x0000000102b8c174 mono_invoke_unhandled_exception_hook + 4424052 (exception.c:1247)
5 SZCAAuth_Xamarin 0x0000000102b40654 mono_handle_exception_internal + 4114004 (mini-exceptions.c:2336)
6 SZCAAuth_Xamarin 0x0000000102b3f354 mono_handle_exception + 4109140 (mini-exceptions.c:2626)
7 SZCAAuth_Xamarin 0x0000000102b3536c mono_arm_throw_exception + 4068204 (exceptions-arm64.c:412)
8 SZCAAuth_Xamarin 0x00000001028ee898 throw_exception + 168
9 SZCAAuth_Xamarin 0x0000000102cbe6b0 xamarin_process_managed_exception + 5678768 (runtime.m:2369)
10 SZCAAuth_Xamarin 0x0000000102cbe530 xamarin_process_managed_exception_gchandle + 5678384 (runtime.m:1132)
11 SZCAAuth_Xamarin 0x0000000102cbe4ec xamarin_ftnptr_exception_handler + 5678316 (runtime.m:1121)
12 SZCAAuth_Xamarin 0x0000000102b3fd18 mono_handle_exception_internal + 4111640 (mini-exceptions.c:2378)
13 SZCAAuth_Xamarin 0x0000000102b3f354 mono_handle_exception + 4109140 (mini-exceptions.c:2626)
14 SZCAAuth_Xamarin 0x0000000102b3536c mono_arm_throw_exception + 4068204 (exceptions-arm64.c:412)
15 SZCAAuth_Xamarin 0x00000001028ee898 throw_exception + 168
16 SZCAAuth_Xamarin 0x00000001028d232c wrapper_castclass_object___castclass_with_cache_object_intptr_intptr + 140
17 SZCAAuth_Xamarin 0x0000000102928cf8 ObjCRuntime_Runtime_ConstructNSObject_T_REF_intptr_System_Type_ObjCRuntime_Runtime_MissingCtorResolution_intptr_intptr + 1920248 (Runtime.cs:1094)
18 SZCAAuth_Xamarin 0x0000000102929624 ObjCRuntime_Runtime_GetNSObject_T_REF_intptr + 1922596 (Runtime.cs:1221)
19 SZCAAuth_Xamarin 0x0000000102959460 ObjCRuntime_Trampolines_SDActionArity1V1_Invoke_intptr_intptr + 2118752 (Trampolines.g.cs:68)
20 SZCAAuth_Xamarin 0x000000010296f694 wrapper_native_to_managed_ObjCRuntime_Trampolines_SDActionArity1V1_Invoke_intptr_intptr + 292
21 SZCAAuth_Xamarin 0x00000001029d19e4 __53-[SZCAStampRequest requestRecord:completion:failure:]_block_invoke + 2611684 (SZCAStampRequest.m:0)
22 SZCAAuth_Xamarin 0x00000001029ce654 __64-[SZCAStampRequest requestWithDic:urlString:completion:failure:]_block_invoke + 2598484 (SZCAStampRequest.m:0)
23 CFNetwork 0x00000001b78b3228 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 32
24 CFNetwork 0x00000001b78c79c8 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 176
25 Foundation 0x00000001b7d6682c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
26 Foundation 0x00000001b7c6ea28 -[NSBlockOperation main] + 72
27 Foundation 0x00000001b7c6defc -[__NSOperationInternal _start:] + 740
28 Foundation 0x00000001b7d68700 __NSOQSchedule_f + 272
29 libdispatch.dylib 0x00000001b6d116c8 _dispatch_call_block_and_release + 24
30 libdispatch.dylib 0x00000001b6d12484 _dispatch_client_callout + 16
31 libdispatch.dylib 0x00000001b6ce8e14 _dispatch_continuation_pop$VARIANT$armv81 + 404
32 libdispatch.dylib 0x00000001b6ce84f8 _dispatch_async_redirect_invoke + 592
33 libdispatch.dylib 0x00000001b6cf4afc _dispatch_root_queue_drain + 344
34 libdispatch.dylib 0x00000001b6cf535c _dispatch_worker_thread2 + 116
35 libsystem_pthread.dylib 0x00000001b6ef417c _pthread_wqthread + 472
36 libsystem_pthread.dylib 0x00000001b6ef6cec start_wqthread + 4
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=== Visual Studio Community 2017 for Mac ===
Version 7.6.11 (build 9)
Installation UUID: 891dc29f-4210-4ba9-a91b-9564b6fea41d
Runtime:
Mono 5.12.0.309 (2018-02/39d89a335c8) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)
Package version: 512000309
=== NuGet ===
版本: 4.3.1.4445
=== .NET Core ===
运行时: /usr/local/share/dotnet/dotnet
运行时版本:
2.1.2
2.1.1
2.0.5
2.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK 版本:
2.1.302
2.1.301
2.1.4
2.0.0
MSBuild SDK: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
版本: 1.6.3
位置:/Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 10.1 (14460.46)
Build 10B61
=== Xamarin.Mac ===
Version: 5.0.0.0 (Visual Studio Community)
Hash: b40230c0
Branch:
Build date: 2018-09-27 11:41:37-0400
=== Xamarin.iOS ===
Version: 12.2.1.10 (Visual Studio Community)
Hash: f2a05edd
Branch: d15-9
Build date: 2018-10-31 18:55:57-0400
=== Xamarin.Android ===
版本: 9.0.0.20 (Visual Studio Community)
Android SDK: /Users/ttlgzmac6/Library/Developer/Xamarin/android-sdk-macosx
受支持的 Android 版本:
2.3 (API 级别 10)
4.0.3 (API 级别 15)
4.4 (API 级别 19)
5.0 (API 级别 21)
6.0 (API 级别 23)
7.0 (API 级别 24)
7.1 (API 级别 25)
8.1 (API 级别 27)
SDK Tools 版本: 25.2.5
SDK 平台工具版本: 27.0.1
SDK 生成工具版本: 27.0.0
Java SDK: /Users/ttlgzmac6/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9
openjdk version "1.8.0-9"
OpenJDK Runtime Environment (build 1.8.0-9-microsoft-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
Android Designer EPL 代码在此处提供:
https://github.com/xamarin/AndroidDesigner.EPL
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 706110009
Git revision: d7cd66f5e3acd3d46ba0b94a0c935378f828bde0
Build date: 2018-10-31 17:17:12+00
Build branch: release-7.6
Xamarin extensions: bc9b985bfcb480b04a208a6d4045adc443a07857
=== Operating System ===
Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
Wed Aug 22 20:13:40 PDT 2018
root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
Steps to Reproduce
I tried to download pdf format file using NSUrlSession and shown progress in UI.
Code Snippet:
Get download progress using following NSUrlSessionDwonloadDelegate: Code to setup delegate and the delegate code itself:
It works fine but need to download three format file with single button click and also show progress of all format file download in a single progress control.
For this I have used CreateDownloadTaskAsync process as below,
await session.CreateDownloadTaskAsync(request, out downloadTask);
Following error comes in Xamarin.iOS:
Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
If removed CreateDownloadTaskAsync process, it works fine. Please help me to resolve this.
Expected Behavior
Actual Behavior
Environment
=== Visual Studio Community 2017 for Mac ===
Version 7.2.2 (build 7) Installation UUID: bb05f286-5b1f-48ab-b0d5-bc61d62b54cb Runtime: Mono 5.4.1.6 (2017-06/1f4613aa1ac) (64-bit) GTK+ 2.24.23 (Raleigh theme)
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime: Not installed SDK: Not installed MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.5.6 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Xamarin.Android ===
Not Installed
=== Xamarin Inspector ===
Not Installed
=== Apple Developer Tools ===
Xcode 8.3.2 (12175) Build 8E2002
=== Xamarin.iOS ===
Version: 11.2.0.11 (Visual Studio Community) Hash: 2f8bbec0 Branch: d15-4-xi Build date: 2017-10-05 20:56:05-0400
=== Xamarin.Mac ===
Version: 3.8.1.0 (Visual Studio Community)
=== Build Information ===
Release ID: 702020007 Git revision: 2236098c68f51eeb447cb947a87371d1e84f6213 Build date: 2017-10-23 11:43:05-04 Xamarin addins: eaa605cf97f25ce184949f32c712b465ca96f665 Build lane: monodevelop-lion-d15-4
=== Operating System ===
Mac OS X 10.12.4 Darwin 16.5.0 Darwin Kernel Version 16.5.0 Fri Mar 3 16:52:33 PST 2017 root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Build Logs
Example Project (If Possible)