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

UWP/Unity: Unity crash when trying to instantiate the WebView as child or with scale zero #3721

Closed
ArDevKarl opened this issue Aug 18, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@ArDevKarl
Copy link

ArDevKarl commented Aug 18, 2023

Description
I'm trying to use the WebView a child of a root object. Therefore I created a Prefab that contains the class "WebView" and its requirements. I want this Prefab to be instantiated as child of another transform and to be at scale = Vector3.zero on initialization.

The Prefab contains a helper class that handles all visial components. Here I want to setup the WebView as child and scale it:

private void Awake()
 {
     _webView = GetComponentInChildren<WebView>();
      _webView .transform.SetParent(root.transform); // <- causes crash
     _webView .transform.localScale = Vector3.zero; // <- causes crash

 }

If I maintain the scale and not change the parent of the WebView Unity or the application won't crash.

Version
WebView2: 0.17.1-pre.5
Unity: 2022.3.7f1

Repro Steps
Instantiate a WebView Prefab and try to change it's parent or scale it to zero.

@ArDevKarl ArDevKarl added the bug Something isn't working label Aug 18, 2023
@novac42
Copy link
Contributor

novac42 commented Aug 18, 2023

Thanks for reporting the issue. @michaelfarnsworth could you please take a look?

@michaelfarnsworth
Copy link
Collaborator

@ArDevKarl I'd double-check that WebView control is ready. You can register a callback via WebView.GetWebViewWhenReady() or listen for the WebViewReady event. Hope that helps.

@ArDevKarl
Copy link
Author

ArDevKarl commented Aug 21, 2023

@ArDevKarl I'd double-check that WebView control is ready. You can register a callback via WebView.GetWebViewWhenReady() or listen for the WebViewReady event. Hope that helps.

Ah thank you, that worked!

Please, make sure to throw an Exception everytime WebView is called while not ready.

@victorhuangwq
Copy link
Collaborator

Please, make sure to throw an Exception everytime WebView is called while not ready.

@ArDevKarl Was this a request directed to the WebView2 team?

@victorhuangwq
Copy link
Collaborator

@ArDevKarl similarly, would you be referring to the Unity's WebView API in this request as well? If so, I would be closing this issue accordingly.

@ArDevKarl
Copy link
Author

ArDevKarl commented Aug 29, 2023

@victorhuangwq Like in the other post #3722 I'm talking about this:
https://learn.microsoft.com/en-us/windows/mixed-reality/develop/advanced-concepts/webview2-unity-plugin

I'll create a Feature Request about this issue.

EDIT: #3746

@nishitha-burman
Copy link
Collaborator

Hi @ArDevKarl,

Closing this issue since the feature request is being tracked in #3746. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants