Wasm types and debug issue

Hi
We have an old wasm project that used much older versions of Elements. Everything worked fine.
Now we tried it to run using the latest versions .2867 and .2885 and found problems:

  1. .2867 has debug info and I can use breakpoints, but .2285 shows the error:
~> Debugger action 'set new breakpoint' failed with an error: Object reference not set to an instance of an object.
~>    at RemObjects.Elements.Debugger.Native.Wasm.WasmDebugger.<Resume>d__0.MoveNext()
~>    at RemObjects.Elements.Debugger.Native.Wasm.WasmDebugger.Resume(Boolean aIgnoreException)
~>    at RemObjects.Elements.Debugger.IslandDebugEngine.IntCreateBP(BreakpointInfo aBP)
~>    at RemObjects.Elements.Debugger.IslandDebugEngine.CreateBreakpoint(Int32 aRow, Int32 aCol, String aFn, String aCond, Int32 aCondKind, Int32 aHitCount, Int32 aHitCountKind)
~>    at RemObjects.Fire.ProjectSystem.DebugSession.setupBreakpoint_AlreadyOnManagedThread____callback(Breakpoint breakpoint, $Delegate_`0 callback)
~>    at RemObjects.Fire.ProjectSystem.DebugSession.doBusy(String name, $Delegate_`0 task)
~> Debugger action 'set new breakpoint' failed with an error: Object reference not set to an instance of an object.
~>    at RemObjects.Elements.Debugger.Native.Wasm.WasmDebugger.<Resume>d__0.MoveNext()
~>    at RemObjects.Elements.Debugger.Native.Wasm.WasmDebugger.Resume(Boolean aIgnoreException)
~>    at RemObjects.Elements.Debugger.IslandDebugEngine.IntCreateBP(BreakpointInfo aBP)
~>    at RemObjects.Elements.Debugger.IslandDebugEngine.CreateBreakpoint(Int32 aRow, Int32 aCol, String aFn, String aCond, Int32 aCondKind, Int32 aHitCount, Int32 aHitCountKind)
~>    at RemObjects.Fire.ProjectSystem.DebugSession.setupBreakpoint_AlreadyOnManagedThread____callback(Breakpoint breakpoint, $Delegate_`0 callback)
~>    at RemObjects.Fire.ProjectSystem.DebugSession.doBusy(String name, $Delegate_`0 task)
Breakpoint not resolved
  1. Created API endpoints using types like Integer, Int64, etc. worked fine. Now both new compiler versions raise exceptions at runtime:
Type: RemObjects.Elements.System.InvalidCastException
Message: Invalid cast
Call Stack:
00000000000C2213 RemObjects.Elements.System.ExternalCalls.IntRaiseException _Module.wasm (webassembly.pas, line 874)
00000000000C2206 RemObjects.Elements.System.ExternalCalls.RaiseException _Module.wasm (webassembly.pas, line 863)
00000000000C7B45 _Module.Program.Main _Module.wasm (program.pas, line 14)
0000000000000000 imp.env.__island_invoke:572 index.html
000000000006F417 RemObjects.Elements.System.WebAssembly.InvokeMethod _Module.wasm (webassembly.pas, line 767)
0000000000070F39 RemObjects.Elements.System.MethodInfo.Invoke _Module.wasm (reflection.pas, line 677)
0000000000057624 RemObjects.Elements.System.WebAssembly.<>c__DisplayClass1.<GetProxyFor>b__2 _Module.wasm (webassembly.pas, line 623)
0000000000027654 WebAssemblyDelegate.Invoke _Module.wasm (task.pas, line 774)
00000000000C2477 RemObjects.Elements.System.ExternalCalls.CallDelegate _Module.wasm (webassembly.pas, line 893)
0000000000000000 res:290 index.html
0000000000000000 index.html


Module.zip (811.3 KB)
Here is a test case showing that object properties that are Int or Int64, like length of array, now return Double type (len variables). All the API functions using strong types stopped working.

  1. There are other errors like:
Type: RemObjects.Elements.System.AbstractMethodException
Message: Abstract method
Call Stack:
00000000001AEBE1 RemObjects.Elements.System.ExternalCalls.IntRaiseException TatukGIS_DK11.wasm (webassembly.pas, line 874)
00000000001AEBD4 RemObjects.Elements.System.ExternalCalls.RaiseException TatukGIS_DK11.wasm (webassembly.pas, line 863)
00000000001B0E08 RemObjects.Elements.System.Utilities.AbstractCall TatukGIS_DK11.wasm (utilities.pas, line 26)
0000000000430BA7 _intf__rtti_t37_gte___1sDictionary_t_2st18__TatukGIS_d_TGIS__CSAbstract_vmthelper0 TatukGIS_DK11.wasm (dictionary.pas, line 351)
000000000045410A TatukGIS.TGIS_CSAbstractList.Add TatukGIS_DK11.wasm (giscsbase.pas, line 4619)

when calling a dictionary method:

if oListWKT.ContainsKey( _obj.WKT ) then

Why the object properties types have changed? We don’t want to use everywhere dynamic.
Can these issues be solved, at least broken debug?

Regards
Artur

My apologies for the delayed response. My college Diego is looking into this and will get back to you soon.

Hi,

for 1) I sent the debug issue to debug team to check it.

About 2) all javascript numbers are internally float, that’s the reason you see the properties as Double type. Doing a pure dynamic javascript call will return the type as is, double in this case.
Honestly, don’t remember if in wasm early stages the default type was integer and then changed properly.
to assign to Int, Int64 you can do using as:

var ilen: Int64 := arr.byteLength as Int64

or wrap the desired object around a DynamicInterface like:

  [DynamicInterface(typeOf(EcmaScriptObject))]
  IArray = public interface
    property byteLength: Integer;
  end;

then:

      var lArr:IArray := uarr as IArray;
      var lLen: Int64 := lArr.byteLength;

for 3 can you provide please an small testcase to check?

Thanks!

Hi,
I checked with debugger team and tested myself again now, and the debug issue 3) is fixed in build .2892

Thanks!

1 Like