TextField breaks WebGL build (Case 1286167)

Bug Report: 1286167

Maybe someone has a workaround?

  1. Observation

When using a TextField (apparently anwhere) in a UI Toolkit based Interface, the WebGL build always fails upon loading with an exception (independent of debug or not). This makes any WebGL build with TextField unusable.

  1. How To Reproduce

Using 2020.1.9f1 / UI Toolkits 1.0.0-preview9, create an empty project and add a single TextField to a UIDocument. It does not matter if you use pure UXML or a C# VisualElement derivative.

Here’s the beginning of the stack trace:

RuntimeError: invalid conversion to integer
__ZN10GUIUtility17AlignRectToDeviceERK5RectTIfERiS4_@http://localhost:50485/Build/Build.wasm:wasm-function[13027]:0x48b2e1
__Z44GUIUtility_CUSTOM_AlignRectToDevice_InjectedRK5RectTIfEPiS3_RS0_@http://localhost:50485/Build/Build.wasm:wasm-function[13129]:0x48db57
_GUIUtility_AlignRectToDevice_Injected_m6999B2692513ECEF19DB2644C1DF627062E14625@http://localhost:50485/Build/Build.wasm:wasm-function[43504]:0x9e8d4b
_GUIUtility_AlignRectToDevice_mAD077BDFEA34F8C66963FF2F7DDEC74319B5B620@http://localhost:50485/Build/Build.wasm:wasm-function[43503]:0x9e8cf8
_GUIUtility_AlignRectToDevice_m5E943EB06F79A20EB45B7E2EB74A4A0399CFAD87@http://localhost:50485/Build/Build.wasm:wasm-function[43530]:0x9e9614
_TextEditor_set_position_m021494940550A18AF6D726639F58E60528813EE8@http://localhost:50485/Build/Build.wasm:wasm-function[43546]:0x9e9ca0
_TextInputBase_SyncTextEngine_mAD5C5DA846084A333C3D57AD5752973A03FC8B2A_gshared@http://localhost:50485/Build/Build.wasm:wasm-function[36194]:0x87199f
__Z70TextInputBase_SyncTextEngine_m936FA9F2B3E8DD781613126B31936BE9C7FE9AF4P55TextInputBase_tA19FB7974DB4833DEA7221618B1A11C8C8B05B87PK10MethodInfo@http://localhost:50485/Build/Build.wasm:wasm-function[27238]:0x6fb9b3
_TextInput_SyncTextEngine_m8DA2D7D90046CB3A97EB0A11550247CBC5E277DC@http://localhost:50485/Build/Build.wasm:wasm-function[27235]:0x6fb992
__ZN18VirtActionInvoker06InvokeEtP12Il2CppObject@http://localhost:50485/Build/Build.wasm:wasm-function[17544]:0x589962
_TextInputBase_UnityEngine_UIElements_ITextInputField_SyncTextEngine_m951D497C9EF59FFFC7DFADB5CEC143671F775977_gshared@http://localhost:50485/Build/Build.wasm:wasm-function[36207]:0x873c0d
__ZN23InterfaceActionInvoker06InvokeEtP11Il2CppClassP12Il2CppObject@http://localhost:50485/Build/Build.wasm:wasm-function[18487]:0x59a4b0
_TextEditorEventHandler__ctor_mCBEDC9750AC4789477201CE1415152E9F45B3575@http://localhost:50485/Build/Build.wasm:wasm-function[27384]:0x7002bb
_KeyboardTextEditorEventHandler__ctor_mEA23A73CF0F5EC55395A1B2AD06BB40AE0FBDC02@http://localhost:50485/Build/Build.wasm:wasm-function[28299]:0x726e22
_TextInputBase__ctor_m723937B74AC47A55E3687073337B595B5EB4C63C_gshared@http://localhost:50485/Build/Build.wasm:wasm-function[36183]:0x871204
__Z61TextInputBase__ctor_mED2E25F02C470F1C2A81F171D6F06AF0A4BC56FBP55TextInputBase_tA19FB7974DB4833DEA7221618B1A11C8C8B05B87PK10MethodInfo@http://localhost:50485/Build/Build.wasm:wasm-function[27257]:0x6fc2ee
_TextInput__ctor_m26221FC6F39AF13BFE920A503E60DD6C6C51AD8A@http://localhost:50485/Build/Build.wasm:wasm-function[27256]:0x6fc2e3
_TextField__ctor_mC9D8E026D80C877BB737413280B492BF511DA21F@http://localhost:50485/Build/Build.wasm:wasm-function[27439]:0x701c95
_TextField__ctor_mB76391B582EC95FB94A07C7D65FDABFF45BC1D20@http://localhost:50485/Build/Build.wasm:wasm-function[27438]:0x701c59
_TextField__ctor_m82234E5370C3A3B47E0036750FED8ACD850D5620@http://localhost:50485/Build/Build.wasm:wasm-function[27437]:0x701c44

Thanks for filling a bug.

It looks like a conversion from a NAN float to int conversion deep in the stack in the constructor of the object: I don’t think there is something you could to do to change that.

We recently did some changes related to the text support: can you check if the error exist with preview 7 and see if you still have the error? Maybe you will have a functional setup doing so.

Thank you very much for the quick response!
Unfortunately, the behaviour persists on UI Toolkit Preview 7 and Preview 3.
I cleaned the project folder from all generated files (library etc.) and restarted the editor, just in case.

Best,

Andreas

I know it’s not yet meant for production - but any chance this might be tackled in a Preview-X release in the foreseeable future?

Please report a bug through Unity! Definitely something we’ll want to fix for the final release, and good chance it makes it into the preview (assuming this bug is something we can fix inside the UI Toolkit package).

Filed in under: Unity Issue Tracker - [WebGL][UI Toolkit] Player crashes when using TextField