Browser.GetElementById()` throws exception when called from `[Export]` class method

Description

Browser.GetElementById() from RemObjects.Elements.WebAssembly.DOM throws an exception (silently caught, not propagated to JavaScript console) when called from a method in an [Export]ed class.

The same API call works perfectly when called from:

  • Non-exported classes
  • Methods called later in the application lifecycle (e.g., from view classes)

Minimal Reproduction

namespace BugRepro;

uses
  RemObjects.Elements.WebAssembly.DOM;

type
  [Export]
  App = public class
  public
    method Start;
    begin
      // This line throws an exception (silently):
      var el := Browser.GetElementById('app-root');

      // This is never reached:
      if el <> nil then begin
        var dwin: dynamic := (el as HTMLElement).ownerDocument.defaultView;
        dwin.console.log('[WASM] SUCCESS');
      end;
    end;
  end;

end.
<!DOCTYPE html>
<html>
<body>
  <div id="app-root"></div>
  <script src="RemObjectsElements.js"></script>
  <script src="BugRepro.js"></script>
  <script>
    BugRepro.instantiate("BugRepro.wasm").then(function(result) {
      console.log('[JS] Creating App...');
      var app = result.App();
      console.log('[JS] App created');
      console.log('[JS] Calling Start()...');
      app.Start();
      console.log('[JS] Start() returned');
      // BUG: No '[WASM] SUCCESS' message appears in console
    });
  </script>
</body>
</html>

Expected Behavior

Browser.GetElementById('app-root') should return the HTMLElement and [WASM] SUCCESS should be logged to console.

Actual Behavior

  • app.Start() returns immediately
  • No console output from WASM code
  • No JavaScript exception thrown
  • The exception is silently caught within WASM runtime

Workaround

Call Browser.GetElementById() from non-exported helper methods or from methods invoked later (not directly from the exported class’s entry point).

Additional Notes

  • Other methods in the same codebase successfully use Browser.GetElementById() without issues
  • The timing appears related - calling it from Start() immediately after WASM instantiation fails
  • Adding [DisableInlining] attribute did not help
  • Using try/except in Oxygene does not catch the exception