Skip to content

Commit da95bb3

Browse files
committed
Fixed current window issue
1 parent e64589e commit da95bb3

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

Ports/JavaScriptPort/STATUS.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ Current State
1616
- Worker host-call misses now emit explicit first-failure diagnostics:
1717
- `PARPAR:DIAG:FIRST_FAILURE:category=host_call_unhandled`
1818
- `PARPAR:DIAG:FIRST_FAILURE:symbol=<nativeSymbol>`
19-
- Latest CI artifacts still ran `main-thread-mode` (before this change) and timed out before `CN1SS:SUITE:FINISHED`.
19+
- Worker native-rebind bug identified and fixed:
20+
- Cause: `translated_app.js` redefined native stubs after `port.js` bind phase in worker startup order.
21+
- Fix: `worker.js` now calls `__parparInstallNativeBindings()` after imports, before handling `start`.
22+
- Latest CI artifacts now run worker mode but fail early before suite start with:
23+
- `PARPAR:DIAG:FIRST_FAILURE:category=runtime_error`
24+
- `TypeError: Cannot read properties of null (reading '__classDef')`
25+
- stack rooted in `HTML5Implementation.__init` after `Window.current()` returned `null`.
2026
- Existing form-constructor recovery diagnostics remain active in `port.js` and are still relevant while migrating.
2127

2228
Next Steps
@@ -25,23 +31,27 @@ Next Steps
2531
1. Validate worker-only boot in CI and local:
2632
- Required markers: `PARPAR:worker-mode`, `PARPAR:DIAG:BOOT:bridgeMode=worker`.
2733
- Any `main-thread-mode` marker now indicates stale artifact or wrong bundle.
28-
2. Separate VM/EDT execution from main-thread host services cleanly:
34+
2. Confirm worker native rebind fix is present in produced bundle:
35+
- In generated `worker.js`, ensure `__parparInstallNativeBindings()` is invoked after imports and before `start`.
36+
- This must eliminate `Window.current()` null stubs from startup execution.
37+
3. Separate VM/EDT execution from main-thread host services cleanly:
2938
- Keep VM/EDT scheduling in worker.
3039
- Ensure main-thread browser APIs are reached through explicit host-call handlers rather than direct worker DOM access.
31-
3. Re-triage screenshot correctness in worker mode only:
40+
4. Re-triage screenshot correctness in worker mode only:
3241
- Re-run screenshot suite and classify first blocker using the existing `TOP_BLOCKER` output.
3342
- Prioritize deterministic runtime failures before throughput tuning.
34-
4. Restore full screenshot count and correctness:
43+
5. Restore full screenshot count and correctness:
3544
- Exit gate remains `CN1SS:SUITE:FINISHED` with expected screenshot artifacts and no `BROWSER:PARPAR_ERROR`.
3645

3746
Important Notes
3847
--------------
3948

4049
- Current CI artifact (`~/Downloads/javascript-ui-tests/browser.log`) shows:
41-
- `PARPAR:main-thread-mode`
42-
- `PARPAR:DIAG:BOOT:bridgeMode=main-thread`
43-
- timeout with `TOP_BLOCKER=unknown|none|none`
44-
- This is consistent with the new migration priority: enforce worker mode first, then debug screenshot behavior.
50+
- `PARPAR:worker-mode`
51+
- `PARPAR:DIAG:BOOT:bridgeMode=worker`
52+
- `TOP_BLOCKER=runtime_error|none|none`
53+
- first crash in `HTML5Implementation.__init` due null window wrapper.
54+
- This is consistent with native rebind order being a primary startup blocker in worker mode.
4555

4656
Known Important Context
4757
-----------------------

vm/ByteCodeTranslator/src/javascript/worker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
self.window = self;
22
self.global = self;
33
/*__IMPORTS__*/
4+
if (typeof self.__parparInstallNativeBindings === 'function') {
5+
self.__parparInstallNativeBindings();
6+
}
47
self.onmessage = function(event) {
58
if (!event || !event.data) {
69
return;

vm/tests/src/test/java/com/codename1/tools/translator/JavascriptTargetIntegrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ void generatesBrowserBundleForJavascriptTarget(CompilerHelper.CompilerConfig con
8282
"Unsupported filesystem natives should fail with an explicit JS-mode message when translated");
8383
assertTrue(worker.contains("importScripts('parparvm_runtime.js');"),
8484
"Worker bootstrap should load the runtime first");
85+
assertTrue(worker.contains("__parparInstallNativeBindings"),
86+
"Worker bootstrap should reapply runtime native bindings after translated app load");
8587
assertTrue(index.contains("browser_bridge.js") && index.contains("js/fontmetrics.js") && index.contains("codenameone-canvas"),
8688
"Generated host page should use the JavaScript port browser shell assets");
8789
assertTrue(browserBridge.contains("cn1HostBridge") && browserBridge.contains("host-callback") && browserBridge.contains("host-call"),

0 commit comments

Comments
 (0)