Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control Throws a Null Exception When Hosted on a ContentView #41

Open
RuddySantos opened this issue Jan 23, 2024 · 4 comments
Open

Control Throws a Null Exception When Hosted on a ContentView #41

RuddySantos opened this issue Jan 23, 2024 · 4 comments

Comments

@RuddySantos
Copy link

I am very new to this. The requirement I have calls for the webview to be hosted in a control (contentView). The HybridView shows fine and callling JS methods etc works. However, when I close the popup window that is hosting the control there is an object reference not set to an instance of an object exception on the OnHandlerChanged --> NavigationCore.

NOTE: This app uses Mopups for pushing/popping pages.

@peterblazejewicz
Copy link
Contributor

Does it happen with regular MAUI BlazorWebView?

@rsantos16
Copy link

We did not try it with the regular BlazorWebView. We are in the process of looking at other solutions but this HybridWebView is the best choice due to our constrains.

@Eilon
Copy link
Owner

Eilon commented Mar 12, 2024

Hi @RuddySantos / @rsantos16 - I tried placing the HybridWebView inside a ContentView and that seemed to work just fine. Do you have a complete repro project that you can share for this?

Or perhaps a full stack trace of the exception?

I saw some places in the code that are possible culprits for a potential bug but it's hard to say without more info.

@johandep
Copy link

johandep commented Nov 1, 2024

Hi @Eilon , we face the same issue and this is the stack trace:

at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2719
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 64
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in `/Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line` 96
   at MobileApp.Program.Main(String[] args) in /Users/johan/mobileapp/Platforms/iOS/Program.cs:line 13
2024-11-01 13:59:40.224525+0100 MobileApp[43460:4908687] Unhandled managed exception: Object reference not set to an instance of an object. (System.NullReferenceException)
   at HybridWebView.HybridWebView.get_PlatformWebView()
   at HybridWebView.HybridWebView.NavigateCore(String url)
   at HybridWebView.HybridWebView.Navigate(String url)
   at HybridWebView.HybridWebView.OnHandlerChanged()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Foundation.NSAsyncSynchronizationContextDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 179

We use the Shell to navigate between pages and when coming back to a page with the HybridWebView component on it, it always crashes in our project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants