Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 24613 [details]
I use a WKWebView to connect to a web page with basic authentication. For this purpose I implemented a WKNavigationDelegate and overrode DidReceiveAuthenticationChallenge. This works perfectly on iOS 10.3, but the app crashes on iOS 11. It seems like it crashes when the method DidReceiveAuthenticationChallenge should be called.
I get this exception:
ObjCRuntime.RuntimeException: The ObjectiveC class 'WKNSURLAuthenticationChallenge' could not be registered, it does not seem to derive from any known ObjectiveC class (including NSObject).
at Registrar.DynamicRegistrar.Lookup (System.IntPtr class, System.Boolean throw_on_error) [0x0008c] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:951
at ObjCRuntime.Class.Lookup (System.IntPtr klass, System.Boolean throw_on_error) [0x00000] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/src/ObjCRuntime/Class.cs:121
at ObjCRuntime.Class.Lookup (System.IntPtr klass) [0x00000] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/src/ObjCRuntime/Class.cs:116
at ObjCRuntime.Runtime.GetNSObject (System.IntPtr ptr, System.Type target_type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution, System.Boolean evenInFinalizerQueue, System.Boolean& created) [0x0003d] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:1154
at ObjCRuntime.Runtime.GetNSObjectWithType (System.IntPtr ptr, System.IntPtr type_ptr, System.Boolean& created) [0x0000c] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:646
at ObjCRuntime.Runtime.get_nsobject_with_type (System.IntPtr obj, System.IntPtr type, System.Boolean& created, System.Int32& exception_gchandle) [0x00003] in /Users/builder/data/lanes/5024/bc9a39fc/source/xamarin-macios/runtime/Delegates.generated.cs:404
It seems like the internal WKNSURLAuthenticationChallenge is indeed a NSProxy which is no NSObject.
See https://github.com/WebKit/webkit/blob/c637754ee7dfca6142e441d2040026903fee0c1f/Source/WebKit/UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.h#L43, https://github.com/WebKit/webkit/blob/0e70cf85f1e146fe7ae6536966655fcadc8e5fa7/Source/WebKit/Shared/Cocoa/WKObject.h#L55 and https://developer.apple.com/documentation/foundation/nsproxy
You can see the problem with the attached project. The third button opens a WKWebView with a delegate which implements DidReceiveAuthenticationChallenge. From the debug messages you can see that it does start loading the url, but it does not execute DidReceiveAuthenticationChallenge.
On a iOS 10.3 device the app works fine.
My app is already in the app store. So this is very important for me as iOS 11 is to be released next week.
If I connect to a http site without authentication, then DidReceiveAuthenticationChallenge is not called and it works. But if the target site uses https, then DidReceiveAuthenticationChallenge should be called (with authMethod=AuthenticationMethodServerTrust) and it crashes again.
This happens in iOS 11, beta 8 and 9.
I can confirm and reproduce the bug. App does work with iOS 10.3 and crashes with 11.0 with the Xcode 9 branch. Here is my environment:
=== Visual Studio Community 2017 for Mac (Preview) ===
Version Preview - Internal Dogfood (7.2 build 576)
Installation UUID: 8d12e55e-3489-463f-ac52-8cb4573c5a81
Mono 220.127.116.11 (d15-3/da80840) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 502000215
=== NuGet ===
=== .NET Core ===
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Xamarin.Android ===
Version: 18.104.22.168 (Visual Studio Community)
Android SDK: /Users/mandel/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
6.0 (API level 23)
7.1 (API level 25)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 25.0.1
Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Android Designer EPL code available here:
=== Xamarin Inspector ===
Build date: Fri, 21 Apr 2017 17:57:12 GMT
=== Apple Developer Tools ===
Xcode 9.0 (13238.4)
=== Xamarin.iOS ===
Version: 10.99.7.32 (Visual Studio Community)
Build date: 2017-09-07 16:10:43+0200
=== Xamarin.Mac ===
Version: 22.214.171.124 (Visual Studio Community)
=== Build Information ===
Release ID: 702000576
Git revision: e3f9469d94ad4932e083ecaa6f998865f15fa452
Build date: 2017-09-05 04:52:47-04
Xamarin addins: 088cef5814d09f9af2866d860110075e14f24435
Build lane: monodevelop-lion-dogfood-vNext
=== Operating System ===
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Thu Jun 15 17:36:27 PDT 2017
I'm also experiencing this issue. Can we expect this to be resolved in time for the iOS 11 release?
Please see bug #59247 for a workaround.
*** This bug has been marked as a duplicate of bug 59247 ***