Xamarin.Auth with WKWebViews fails for IOS < 11

JanettHolstJanettHolst DKUniversity ✭✭

I am using Xamarin.Auth with WKWebViews in Xamarin.IOS.

Problem: It fails on IOS 10 and lower. In Visual Studio App Center I can see the following in the device log. It's the only trace we have since the IOS 10 emulators are currently not working for us.
It happens in the moment that the user clicks "Login" and is supposed to be authenticated and redirected.

Happens on all IOS 9 and 10 devices, but here is one example from VS App Center:
Apple iPad Air 2
iOS 10.3.3:

Feb 15 00:50:08 iPad SpringBoard[219] : User Event Notification fired
Feb 15 00:50:08 iPad AulaNative.iOS(CoreFoundation)[248] : -[WKWebsiteDataStore httpCookieStore]: unrecognized selector sent to instance 0x17842ccc0
Feb 15 00:50:08 iPad AulaNative.iOS(CoreFoundation)[248] : -[WKWebsiteDataStore httpCookieStore]: unrecognized selector sent to instance 0x17842ccc0
Feb 15 00:50:08 iPad AulaNative.iOS[248] :
Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[WKWebsiteDataStore httpCookieStore]: unrecognized selector sent to instance 0x17842ccc0
Native stack trace:********
0 CoreFoundation 0x000000018e062ff8 + 148
1 libobjc.A.dylib 0x000000018cac4538 objc_exception_throw + 56
2 CoreFoundation 0x000000018e069ef4 + 0
3 CoreFoundation 0x000000018e066f54 + 916
4 CoreFoundation 0x000000018df62d4c _CF_forwarding_prep_0 + 92
5 AulaNative.iOS 0x0000000100b1aae8 AulaNative.iOS + 11184872
6 AulaNative.iOS 0x000000010121a674 AulaNative.iOS + 18523764
7 AulaNative.iOS 0x000000010026c618 AulaNative.iOS + 2082328
8 AulaNative.iOS 0x00000001005d2cd8 AulaNative.iOS + 5647576
9 AulaNative.iOS <\M-b\M^@\M-&;>
Feb 15 00:50:08 iPad AulaNative.iOS[248] : Unhandled managed exception:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[WKWebsiteDataStore httpCookieStore]: unrecognized selector sent to instance 0x17842ccc0
Native stack trace:
0 CoreFoundation 0x000000018e062ff8 + 148
1 libobjc.A.dylib 0x000000018cac4538 objc_exception_throw + 56
2 CoreFoundation 0x000000018e069ef4 + 0
3 CoreFoundation 0x000000018e066f54 + 916
4 CoreFoundation 0x000000018df62d4c _CF_forwarding_prep_0 + 92
5 AulaNative.iOS 0x0000000100b1aae8 AulaNative.iOS + 11184872
6 AulaNative.iOS 0x000000010121a674 AulaNative.iOS + 18523764
7 AulaNative.iOS 0x000000010026c618 AulaNative.iOS + 2082328
8 AulaNative.iOS 0x00000001005d2cd8 AulaNative.iOS + 5647576
9 AulaNative.iOS 0x00000001034a8c64 <\M-b\M^@\M-&;>
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: Stacktrace:
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical:
Native stacktrace:
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 0 AulaNative.iOS 0x0000000103497dc8 AulaNative.iOS + 54689224
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 1 libsystem_platform.dylib 0x000000018d12131c _sigtramp + 52
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 2 libsystem_pthread.dylib 0x000000018d127264 pthread_kill + 112
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 3 libsystem_c.dylib 0x000000018cfd19c4 abort + 140
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 4 AulaNative.iOS 0x00000001035f446c xamarin_get_block_descriptor + 5216
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 5 AulaNative.iOS 0x00000001034e32f0 AulaNative.iOS + 54997744
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 6 AulaNative.iOS 0x00000001034977d8 AulaNative.iOS + 54687704
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 7 AulaNative.iOS 0x000000010349824c AulaNative.iOS + 54690380
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 8 AulaNative.iOS 0x000000010348d214 AulaNative.iOS + 54645268
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 9 AulaNative.iOS 0x0000000100609988 AulaNative.iOS + 5872008
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 10 AulaNative.iOS 0x0000000101396da0 AulaNative.iOS + 20082080
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 11 AulaNative.iOS 0x00000001005d2cd8 AulaNative.iOS + 5647576
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 12 AulaNative.iOS 0x00000001034a8c64 AulaNative.iOS + 54758500
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 13 AulaNative.iOS 0x000000010352dc78 AulaNative.iOS + 55303288
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 14 AulaNative.iOS 0x0000000103531590 AulaNative.iOS + 55317904
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 15 AulaNative.iOS 0x0000000100157bc4 AulaNative.iOS + 949188
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 16 AulaNative.iOS 0x000000010015bb44 AulaNative.iOS + 965444
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 17 Foundation 0x000000018eb5750c + 340
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 18 CoreFoundation 0x000000018e01142c + 24
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 19 CoreFoundation 0x000000018e010d9c + 540
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 20 CoreFoundation 0x000000018e00e9a8 + 744
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 21 CoreFoundation 0x000000018df3eda4 CFRunLoopRunSpecific + 424
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 22 GraphicsServices 0x000000018f9a9074 GSEventRunModal + 100
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 23 UIKit 0x00000001941f2c9c UIApplicationMain + 208
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 24 AulaNative.iOS 0x0000000100c4ade8 AulaNative.iOS + 12430824
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 25 AulaNative.iOS 0x000000010122a7f0 AulaNative.iOS + 18589680
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 26 AulaNative.iOS 0x00000001002e30cc AulaNative.iOS + 2568396
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 27 AulaNative.iOS 0x00000001005d2cd8 AulaNative.iOS + 5647576
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 28 AulaNative.iOS 0x00000001034a8c64 AulaNative.iOS + 54758500
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 29 AulaNative.iOS 0x000000010352dc78 AulaNative.iOS + 55303288
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 30 AulaNative.iOS 0x0000000103533b5c AulaNative.iOS + 55327580
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 31 AulaNative.iOS 0x000000010348913c AulaNative.iOS + 54628668
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 32 AulaNative.iOS 0x00000001035fb720 xamarin_localized_string_format_9 + 3244
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 33 AulaNative.iOS 0x0000000100236b30 AulaNative.iOS + 1862448
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical: 34 libdyld.dylib 0x000000018cf4d59c + 4
Feb 15 00:50:08 iPad AulaNative.iOS[248] : critical:

=================================================================

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.

=================================================================

This is the code used to set it up:

AuthenticationState.Authenticator = new AulaOAuth2Authenticator("[...]", null, "[...]", new Uri(authoriseUrl), new Uri(redirectUrl), new Uri(accessTokenUrl), null, false); AuthenticationState.Authenticator.ClearCookiesBeforeLogin = true;
and it's initialized as follows:

PresentViewController(AuthenticationState.Authenticator.GetUI(), true, null);

Am I doing something wrong ?

Posts

  • JanettHolstJanettHolst DKUniversity ✭✭

    FYI: We always clear cookies - so if there is a way we can just remove the WKWebsiteDataStore completely from the picture this would also be helpful

Sign In or Register to comment.