WebAssembly and factory method



If I call a factory method on the JS side, e.g.

var obj = factory.CreateTestObject();


function Factory.CreateTestObject() : TestObject ;
  Result := new TestObject();
end ; 

then WASM fails with

Exception: RemObjects.Elements.System.ArgumentException: Unknown type for o

If I call the constructor directly (JS side) then everything’s fine

var obj = lib.TestObject();

It seems that there is a problem when a method which returns an object is called from JS.

Hmm. can you send us a complete test case for this?

Here you are.

wasm_factory.zip (645.8 KB)


For some reason Web\index.html is missing from the zip…

It is inside Bin\Debug\WebAssembly and the project is modified accordingly so it should start debugging if you hit Start.

Found it, and reproduced.

Logged as bugs://E25390.

bugs://E25390 was closed as fixed.

I’m testing Elements and the problem seems to remain somehow. It is no longer easily reproducible, I’ve tried with different combinations of objects, arguments and factory methods but to no success. However, my “big” project fails consistently with the following stack trace (I stripped the unnecessary parts):

Uncaught RuntimeError: unreachable executed
    res RemObjectsElements.js:267
    onTestClick index.html:78
    onclick index.html:1
RemObjectsElements.js line 699 > WebAssembly.instantiate:6158988:1
    ElementsRaiseException RemObjectsElements.js line 699 > WebAssembly.instantiate:6158988
    ms_t10__1sExternalCallse_RaiseExceptionnp_vnp_vno RemObjectsElements.js line 699 > WebAssembly.instantiate:6158767
    ms_ta__1sConvert8_ToUInt32no RemObjectsElements.js line 699 > WebAssembly.instantiate:6124128
    ms_te__1sWebAssemblye_UnwrapIfNeedednt7__1sTypeno RemObjectsElements.js line 699 > WebAssembly.instantiate:5993114
    mi_tnte__1sWebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt13__1sEcmaScriptObject RemObjectsElements.js line 699 > WebAssembly.instantiate:5990807
    mi_t16__1sWebAssemblyDelegate6_Invokent13__1sEcmaScriptObject RemObjectsElements.js line 699 > WebAssembly.instantiate:5953478
    __island_call_delegate RemObjectsElements.js line 699 > WebAssembly.instantiate:6159046
    res RemObjectsElements.js:267
    onTestClick index.html:78
    onclick index.html:1

The exception is still

Exception: RemObjects.Elements.System.ArgumentException: Unknown type for o

I’ll keep trying to find a test case.

1 Like

Found it! There is a problem with inheritance. If the actual type is returned by the factory method then everything’s fine, if a base type is returned then it fails. See the attached test case.

A similar problem is with method arguments - if a method takes a base type as an argument and you pass a derived type you get the same exception.

wasm_newobj1.zip (634.0 KB)

bugs://E25390 was reopened.

Marc, could you provide an estimate on when this problem might be resolved? This one is critical for me. Also, if it’s done before Friday would it be possible to get a private build?

I’ll check with the team, but this has only been re-opened on Friday,…


bugs://E25390 was closed as fixed.