Error building VCL webassembly sample project

Diego,

Thanks for the help.

My gut said that it wasn’t necessary to create the form, but I got pretty much the same error both ways. That just happens to be the last way I tested it.

Here is the error with the change (I think it is unchanged)

WebAssembly file VclRoTest.wasm has been loaded.
RemObjectsElements.js:485 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
imp.env.__island_ajaxRequestBinary @ RemObjectsElements.js:485
.Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssembly11_AjaxRequestBinaryns @ wasm-01b2454e-982:85
.Lmi_t3c_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TResourceStream3__d_ni64nt24_RemObjects_d_Elements_d_RTL_d_String @ wasm-01b2454e-981:34
.Lmi_t38_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TCustomForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b2454e-1254:168
.Lmi_t32_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b2454e-1257:7
.Lmi_t12_VclRoTest_d_TForm13__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b2454e-7456:27
.Lmi_t39_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TApplicationa_CreateFormnt25_RemObjects_d_Elements_d_System_d_Typen_r_m_v_o @ wasm-01b2454e-860:550
mi_t13_VclRoTest_d_Program4_Main @ wasm-01b2454e-7459:126
imp.env.__island_invoke @ RemObjectsElements.js:443
.Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o @ wasm-01b2454e-6590:302
.Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o @ wasm-01b2454e-5773:1089
.Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-01b2454e-6938:429
.Lmi_t34_RemObjects_d_Elements_d_System_d_WebAssemblyDelegate6_Invokent31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-01b2454e-6924:33
__island_call_delegate @ wasm-01b2454e-6962:18
res @ RemObjectsElements.js:246
(anonymous) @ (index):14
Promise.then (async)
(anonymous) @ (index):11
RemObjectsElements.js:277 Fatal exception in WebAssembly!
RemObjectsElements.js:277 Exception: RemObjects.Elements.System.NullReferenceException: Member access on null reference; for expression: self
wasm-01b2454e-50:27 Uncaught (in promise) RuntimeError: unreachable
    at ElementsRaiseException (wasm-function[50]:74)
    at .Lmi_t39_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TApplicationd_get__MainForm (wasm-function[877]:96)
    at .Lmi_t32_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent (wasm-function[1257]:34)
    at .Lmi_t12_VclRoTest_d_TForm13__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent (wasm-function[7456]:62)
    at .Lmi_t39_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TApplicationa_CreateFormnt25_RemObjects_d_Elements_d_System_d_Typen_r_m_v_o (wasm-function[860]:1347)
    at mi_t13_VclRoTest_d_Program4_Main (wasm-function[7459]:300)
    at imp.env.__island_invoke (https://www.notepage.net/download/dev/wa/wasm/RemObjectsElements.js:443:38)
    at .Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o (wasm-function[6590]:623)
    at .Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o (wasm-function[5773]:2863)
    at .Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[6938]:988)

Ok Chris2, I reproduced your issue and that worked for me:

please, modify the code at Program.cs using:
Application = new TApplication(null);
Application.Initialize();
Application.CreateForm(typeOf(TForm1), ref Form1);
Application.Run();

note NOT declaring Application, we are using a global var (declared in Application unit) saving GC to free the instance.

Yes, that worked!

Thanks you so much for the help. I never would have thought to do it that way.

I have built (and attached) a new Hydrogene version of the Sample-Wasm from

ElementsSamples/Oxygene/Island/Delphi VCL/Sample-Wasm/

I’ve made it as closely as possible to the Oxygene version. It works great.

Feel free to add it to your Git ElementSamples repo.

Sample-Wasm.zip (3.1 KB)