UI Toolkit + WebGPU + C/C++ Multithreading?

…it doesn’t seem to be supported, since it’s crashing with a “memory access out of bounds”.

On WebGL it works, and on WebGPU without C/C++ Multithreading it also works, but I am working on a WebGPU project that could really use C/C++ Multithreading, since it brings 30% better framerate (with all the UI removed).

Anyone knows of plans to support it?

Did you create the simplemost use case for this? Ie new project, a single UI document with a label or button on it. Since you don’t mind using the leading edge tech it can’t hurt to try 6.1 beta as well.

If your simple test case crashes use Help - Report a Bug to send this over for review.

UI toolkit schedule native job with nothing fancy. I wouldn’t expect any problem. Do you have a stacktrace to share?

Probably worth filling a bug for investigation.

Thanks guys.

I submitted a bug report with a minimal project, IN-94167.

Only a basic ui toolkit ui from the getting started page of ui toolkit - a label, a button, a text field and a checkbox.

I will try 6.1 but it’s not an option for me to use it for the project at the moment.

Here’s the stack trace(s):

threadPrintErr @ Build.worker.js:24
Build.worker.js:24 RuntimeError: memory access out of bounds
    at GC_gcj_malloc (http://localhost:37168/Build/Build.wasm:wasm-function[734]:0xf0090)
    at il2cpp::vm::Object::NewAllocSpecific(Il2CppClass*) (http://localhost:37168/Build/Build.wasm:wasm-function[1897]:0x136e3d)
    at il2cpp::vm::Object::New(Il2CppClass*) (http://localhost:37168/Build/Build.wasm:wasm-function[1898]:0x136eab)
    at il2cpp_codegen_object_new(Il2CppClass*) (http://localhost:37168/Build/Build.wasm:wasm-function[47206]:0x1079d7c)
    at TextHandleTemporaryCache_AddTextInfoToCache_m5FC534D96C0BFDD0AF066A5505F2D5FF653EE00D (http://localhost:37168/Build/Build.wasm:wasm-function[120837]:0x1ffe553)
    at TextHandle_AddTextInfoToTemporaryCache_m99B5D63C51AEC0B3494DF6750C1B0F6648C0355C (http://localhost:37168/Build/Build.wasm:wasm-function[120771]:0x1ffa979)
    at UITKTextHandle_UpdateMesh_mF406787AD67462A60BA86A84700FCE9B960F423D (http://localhost:37168/Build/Build.wasm:wasm-function[175095]:0x295d315)
    at GenerateTextJobData_Execute_m5A4DBB5B383EB92550B8134B11CA49EBE331C29A (http://localhost:37168/Build/Build.wasm:wasm-function[175188]:0x296767f)
    at ParallelForJobStruct_1_Execute_m7D2978E2C1A5DCBB0809901499DDBF778DF9D8C3_gshared (http://localhost:37168/Build/Build.wasm:wasm-function[190172]:0x2c46111)
    at ExecuteJobFunction_Invoke_m89689E91386A5EF72135B3BD1BE296855EB75980_OpenStatic(ExecuteJobFunction_t9F81A62710BE572DB5B1CA260179378CB120B923*, GenerateTextJobData_t7A10E34B01929D66C91DD360ABCE0155BDDAC636*, long, long, JobRanges_t5A1CDFF3E0DB1197050E1E28617B517C15AF6DC3*, int, MethodInfo const*) (http://localhost:37168/Build/Build.wasm:wasm-function[199753]:0x2db0b89)
threadPrintErr @ Build.worker.js:24
Build.worker.js:24 RuntimeError: memory access out of bounds
    at il2cpp::icalls::mscorlib::System::Object::GetType(Il2CppObject*) (http://localhost:37168/Build/Build.wasm:wasm-function[47283]:0x107c8e5)
    at Delegate_Combine_m1F725AEF318BE6F0426863490691A6F4606E7D00 (http://localhost:37168/Build/Build.wasm:wasm-function[204803]:0x2ea2708)
    at TextHandleTemporaryCache_AddTextInfoToCache_m5FC534D96C0BFDD0AF066A5505F2D5FF653EE00D (http://localhost:37168/Build/Build.wasm:wasm-function[120837]:0x1ffe606)
    at TextHandle_AddTextInfoToTemporaryCache_m99B5D63C51AEC0B3494DF6750C1B0F6648C0355C (http://localhost:37168/Build/Build.wasm:wasm-function[120771]:0x1ffa979)
    at UITKTextHandle_UpdateMesh_mF406787AD67462A60BA86A84700FCE9B960F423D (http://localhost:37168/Build/Build.wasm:wasm-function[175095]:0x295d315)
    at GenerateTextJobData_Execute_m5A4DBB5B383EB92550B8134B11CA49EBE331C29A (http://localhost:37168/Build/Build.wasm:wasm-function[175188]:0x296767f)
    at ParallelForJobStruct_1_Execute_m7D2978E2C1A5DCBB0809901499DDBF778DF9D8C3_gshared (http://localhost:37168/Build/Build.wasm:wasm-function[190172]:0x2c46111)
    at ExecuteJobFunction_Invoke_m89689E91386A5EF72135B3BD1BE296855EB75980_OpenStatic(ExecuteJobFunction_t9F81A62710BE572DB5B1CA260179378CB120B923*, GenerateTextJobData_t7A10E34B01929D66C91DD360ABCE0155BDDAC636*, long, long, JobRanges_t5A1CDFF3E0DB1197050E1E28617B517C15AF6DC3*, int, MethodInfo const*) (http://localhost:37168/Build/Build.wasm:wasm-function[199753]:0x2db0b89)
    at ExecuteJobFunction_Invoke_m89689E91386A5EF72135B3BD1BE296855EB75980_gshared (http://localhost:37168/Build/Build.wasm:wasm-function[199755]:0x2db0c78)
    at RuntimeInvoker_TrueVoid_t4861ACF8F4594C3437BB48B6E56783494B843915_VoidU2A_t104EAEFBD2D237A8C29618913DA9B4D99355E965_IntPtr_t_IntPtr_t_VoidU2A_t104EAEFBD2D237A8C29618913DA9B4D99355E965_Int32_t680FF22E76F6EFAD4375103CBBFFA0421349384C(void (*)(), MethodInfo const*, void*, void**, void*) (http://localhost:37168/Build/Build.wasm:wasm-function[227843]:0x31b4a55)
2 Likes

Thanks for the bug report!

At first glance it seems because we mix c# and c++ jobs in the text creation and it trick the scheduler into executing c# jobs outside of the main thread.