daniilch
Topic Author
Posts: 11
Joined: 02 Mar 2022, 10:05

Crash when using EventManager in Unity editor play mode

10 Jun 2022, 10:36

Hello. I'm using Noesis in Unity, and I have a problem with EventManager class. I'm trying to implement a built-in virtual keyboard in my app, so I need to detect when any TextBox gets keyboard focus. An ideal solution for me is to register applcation-wide event handler:
EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotFocus), handledEventsToo: true);
It works, but the problem comes from unexpected (at least for me) side: when I'm trying to restart application in Unity editor I get an error message in Unity log that
Class handler for event 'GotKeyboardFocus' already registered
After that selecting any TextBox results in Unity editor crash:
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) Noesis.View.Noesis_View_TouchUp (System.Runtime.InteropServices.HandleRef,int,int,ulong) [0x00015] in <5248267203254a0d863fdc559e5f138d>:0
  at Noesis.View.TouchUp (int,int,ulong) [0x00001] in D:\Projects\Repos\mrs-redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\API\Core\View.cs:296
  at NoesisView.UpdateTouch () [0x0009f] in D:\Projects\Repos\mrs-redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\NoesisView.cs:944
  at NoesisView.UpdateInputs (single) [0x0001f] in D:\Projects\Repos\mrs-redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\NoesisView.cs:1066
  at NoesisView.ExternalUpdateInternal () [0x00038] in D:\Projects\Repos\mrs-redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\NoesisView.cs:1139
  at NoesisView.LateUpdate () [0x0000f] in D:\Projects\Repos\mrs-redesign\Library\PackageCache\com.noesis.noesisgui@36e5d70d8b\Runtime\NoesisView.cs:1120
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00020] in <695d1cc93cca45069c528c15c9fdd749>:0

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Received signal SIGSEGV
Stack trace:
RtlLookupFunctionEntry returned NULL function. Aborting stack walk.
<Missing stacktrace information>
I guess the problem is that Noesis does not clear event registrations in EventManager when Unity unloads domain when restarting play mode. Any help is appreciated.

Unity version 2020.3.25f1, Noesis package version 3.1.4
 
User avatar
sfernandez
Site Admin
Posts: 3005
Joined: 22 Dec 2011, 19:20

Re: Crash when using EventManager in Unity editor play mode

10 Jun 2022, 11:53

This is a bug, could you please report it in our bugtracker?
As you said class event handlers are not properly unregistered when the domain is unloaded.

Anyway, our library provides a callback, Noesis.GUI.SetSoftwareKeyboardCallback(), to show a software keyboard when any TextBox/PasswordBox is selected. In Unity our plugin is hooking to that callback to show Unity's TouchScreenKeyboard. But you can override that to show your custom virtual keyboard.
 
daniilch
Topic Author
Posts: 11
Joined: 02 Mar 2022, 10:05

Re: Crash when using EventManager in Unity editor play mode

10 Jun 2022, 13:51

our library provides a callback, Noesis.GUI.SetSoftwareKeyboardCallback()
Oh, that's neat! Thank you, I'll try to use that one. Sure, I'll file a bug.

UPD: done - https://www.noesisengine.com/bugs/view.php?id=2359
 
User avatar
sfernandez
Site Admin
Posts: 3005
Joined: 22 Dec 2011, 19:20

Re: Crash when using EventManager in Unity editor play mode

15 Jun 2022, 10:44

Thanks for the report, we will fix it as soon as possible.

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 2 guests