xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

NullReferenceException on IOS. #424

Open JanettHolst290490 opened 5 years ago

JanettHolst290490 commented 5 years ago

Xamarin.Auth Issue

I haven't reproduced it. All I see is this exception in my logs. Hope you can use it for something. Sorry for the little information.

Exception (NullReferenceException): Object reference not set to an instance of an object. at Xamarin.Auth.WebAuthenticatorController+UIWebViewDelegate.LoadingFinished (UIKit.UIWebView webView) <0x1017c8fb0 + 0x00054> in <90b79cf7264c430a928c8ab5cce5ca18#beecb3912fa11429e4f57fcd07479bca>:0 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x1009c3bbc + 0x00047> in <c7623ebd6c5c49808d04bacb43da90c0#beecb3912fa11429e4f57fcd07479bca>:0 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1009c3b00 + 0x0005b> in <c7623ebd6c5c49808d04bacb43da90c0#beecb3912fa11429e4f57fcd07479bca>:0 at AulaNative.iOS.Application.Main (System.String[] args) <0x1003786c4 + 0x0003b> in <552d4a1a779e4272bf8ca9667ab8a860#beecb3912fa11429e4f57fcd07479bca>:0

Version

Steps to reproduce

We are using many third party IdPs. And it is working in the cases we can reproduce. My guess is that one of them returns an error. We are using the Authenticator like this:

AuthenticationState.Authenticator = new OAuth2Authenticator(
                clientId,
                null,
                scope,
                new Uri(authoriseUrl),
                new Uri(redirectUrl),
                new Uri(accessTokenUrl),
                null,
                false);
            AuthenticationState.Authenticator.ClearCookiesBeforeLogin = true;
            AuthenticationState.Authenticator.ShowErrors = false;
            AuthenticationState.Authenticator.AllowCancel = true;

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

Platform:

Xamarin.IOS. The code is implemented in a shared .NET Standard 2.0 Library.

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.2.4 (build 17) Installation UUID: 4c2dc437-7869-4392-9b24-f24a2c4f02e7 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.14.0.85 (d16-2-fix-mac-updates / 86973979)

Package version: 600000327

=== Mono Framework MDK ===

Runtime: Mono 6.0.0.327 (2019-02/f8ea05bddcb) (64-bit) Package version: 600000327

=== NuGet ===

Version: 5.1.0.6013

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 2.1.12 2.1.11 2.1.9 2.1.8 2.1.2 2.1.1 2.0.5 2.0.0 SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks SDK Versions: 2.1.701 2.1.700 2.1.505 2.1.504 2.1.302 2.1.301 2.1.4 2.0.0 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/Current/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.11 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 9.4.1.0 (Visual Studio Enterprise) Commit: xamarin-android/d16-2/ebd65c9 Android SDK: /Users/janettholst/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.4 SDK Build Tools Version: 29.0.2

Build Information: Mono: mono/mono/2019-02@e6f5369c2d2 Java.Interop: xamarin/java.interop/d16-2@d64ada5 LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-2@6f6c969

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/janettholst/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9 1.8.0-9 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.60 Hash: 686c817 Branch: remotes/origin/d16-2 Build date: 2019-08-07 15:49:58 UTC

=== Apple Developer Tools ===

Xcode 10.3 (14492.2) Build 10G8

=== Xamarin.Mac ===

Version: 5.14.0.114 (Visual Studio Enterprise) Hash: c6691164 Branch: d16-2 Build date: 2019-07-29 15:54:06-0400

=== Xamarin.iOS ===

Version: 12.14.0.114 (Visual Studio Enterprise) Hash: c6691164 Branch: d16-2 Build date: 2019-07-29 15:54:05-0400

=== 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

=== Xamarin Designer ===

Version: 16.2.0.379 Hash: 3f0652957 Branch: remotes/origin/d16-2 Build date: 2019-08-01 17:32:50 UTC

=== Build Information ===

Release ID: 802040017 Git revision: 9b155edbf23e9fe8b477b3236a342164fabf5f6b Build date: 2019-08-16 00:21:01+00 Build branch: release-8.2 Xamarin extensions: 9f2598b5f2371ba2903988c2cd87a9759d0255f2

=== Operating System ===

Mac OS X 10.14.6 Darwin 18.7.0 Darwin Kernel Version 18.7.0 Tue Aug 20 16:57:14 PDT 2019 root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Expected behaviour

It does not throw a NullReferenceException, but instead something useful? If it's an error then at least something to clarify what is going wrong.

Actual behaviour

Exception (NullReferenceException): Object reference not set to an instance of an object. at Xamarin.Auth.WebAuthenticatorController+UIWebViewDelegate.LoadingFinished (UIKit.UIWebView webView) <0x1017c8fb0 + 0x00054> in <90b79cf7264c430a928c8ab5cce5ca18#beecb3912fa11429e4f57fcd07479bca>:0 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x1009c3bbc + 0x00047> in <c7623ebd6c5c49808d04bacb43da90c0#beecb3912fa11429e4f57fcd07479bca>:0 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1009c3b00 + 0x0005b> in <c7623ebd6c5c49808d04bacb43da90c0#beecb3912fa11429e4f57fcd07479bca>:0 at AulaNative.iOS.Application.Main (System.String[] args) <0x1003786c4 + 0x0003b> in <552d4a1a779e4272bf8ca9667ab8a860#beecb3912fa11429e4f57fcd07479bca>:0

JanettHolst290490 commented 5 years ago

This error occurs to 300 people per day, and it makes the app crash, so it could be really great if someone has time to prioritize this.

JanettHolst290490 commented 4 years ago

Still happening. It happens when some error occurs. We just don't know which error because it throws an exception.