You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we try to write our custom WkWebViewRenderer, we want to override some custom behavior from the NavigationDelegate, but we still want to to keep the default behavior from the Xamarin.Forms Delegate, that's why we will create a custom delegate that will reference to the Xamarin.Forms Delegate.
Problem is when doing this, it will cause the app to crash due to some internal code.
NOTE: We don't have the same error from the previous stable Xamarin.iOS version.
Steps to Reproduce
Create a custom WebViewRenderer that inherit from WkWebViewRenderer
Set this.NavigationDelegate = new WKCustomWebViewNavDelegate(this, this.NavigationDelegate)
In DecidePolicy, try to call the referenced old "NavigationDelegate" (that comes from WkWebViewRenderer - CustomWebViewNavigationDelegate)
Run the web view
Expected Behavior
The webview should run fine, in the end it's just calling the old "delegate", which should not causing any problem
Actual Behavior
App crash due to:
System.ArgumentException
Key already in the list
at System.Runtime.CompilerServices.ConditionalWeakTable`2[TKey,TValue].Add (TKey key, TValue value) [0x000a8] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Runtime.CompilerServices/ConditionalWeakTable.cs:242
at ObjCRuntime.Runtime.ReleaseBlockWhenDelegateIsCollected (System.IntPtr block, System.Delegate delegate) [0x0001c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:2049
at ObjCRuntime.Runtime.CreateBlockProxy (System.Reflection.MethodInfo method, System.IntPtr block) [0x0001f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:1017
at ObjCRuntime.Runtime.CreateBlockProxy (System.IntPtr method, System.IntPtr block) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:509
at ObjCRuntime.Runtime.create_block_proxy (System.IntPtr method, System.IntPtr block, System.IntPtr* exception_gchandle) [0x00007] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:407
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr(intptr,intptr,intptr,intptr,intptr)
at WebKit.WKNavigationDelegate_Extensions.DecidePolicy (WebKit.IWKNavigationDelegate This, WebKit.WKWebView webView, WebKit.WKNavigationAction navigationAction, System.Action`1[T] decisionHandler) [0x00030] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/WebKit/WKNavigationDelegate.g.cs:81
at LifeCloud.iOS.Renderers.WebViewRender+WKCustomWebViewNavDelegate.DecidePolicy (WebKit.WKWebView webView, WebKit.WKNavigationAction navigationAction, System.Action`1[T] decisionHandler) [0x00001] in /Users/huyvu/Documents/Workplace/LifeCloud/LifeCloud/LifeCloud.iOS/Renderers/WebViewRender.cs:147
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:58
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.6/src/Xamarin.iOS/UIKit/UIApplication.cs:84
at LifeCloud.iOS.Application.Main (System.String[] args) [0x00001] in /Users/huyvu/Documents/Workplace/LifeCloud/LifeCloud/LifeCloud.iOS/Main.cs:17
When we try to write our custom WkWebViewRenderer, we want to override some custom behavior from the NavigationDelegate, but we still want to to keep the default behavior from the Xamarin.Forms Delegate, that's why we will create a custom delegate that will reference to the Xamarin.Forms Delegate.
Problem is when doing this, it will cause the app to crash due to some internal code.
NOTE: We don't have the same error from the previous stable Xamarin.iOS version.
Steps to Reproduce
this.NavigationDelegate = new WKCustomWebViewNavDelegate(this, this.NavigationDelegate)
DecidePolicy
, try to call the referenced old "NavigationDelegate" (that comes fromWkWebViewRenderer
-CustomWebViewNavigationDelegate
)Expected Behavior
The webview should run fine, in the end it's just calling the old "delegate", which should not causing any problem
Actual Behavior
App crash due to:
Environment
Version information
The text was updated successfully, but these errors were encountered: