|
3 | 3 | JavaScript Port Status (ParparVM) |
4 | 4 | ================================= |
5 | 5 |
|
6 | | -Last updated: 2026-04-07 |
| 6 | +Last updated: 2026-04-09 |
7 | 7 |
|
8 | 8 | Current State |
9 | 9 | ------------- |
10 | 10 |
|
11 | | -- **WORKAROUND IN PLACE**: `ensureDisplayEdt()` in port.js creates synthetic EDT if missing. |
12 | | -- **FIX**: `initImpl` shim in port.js guards against `getClass().getName()` failures during `Display.init()`. |
13 | | - - In the ParparVM JS translation, `Object.getClass()` may return null or `Class.getName()` may return an underscore-separated name, |
14 | | - causing `String.lastIndexOf('.')` to return -1 and a subsequent `substring(0, -1)` to throw. |
15 | | - - The shim catches these errors, calls `init(m)` directly, and sets `packageName` from the bootstrap object's class metadata. |
16 | | -- **FIX**: Simplified `ParparVMBootstrap.bootstrap()` to match `JavaScriptPortBootstrap.bootstrap()` structure. |
17 | | - - Removed intermediate `hasNativeTheme()`/`installNativeTheme()` calls between `Display.init()` and `bootstrap.run()`. |
18 | | - - These calls were triggering additional failures in the partially-initialized Display state. |
19 | | -- **Removed**: Bogus root-level `ParparVMBootstrap.java` that had incorrect imports and structure. |
20 | | -- **Remaining issue**: `IllegalStateException` still caught in fallback handlers even after EDT is set. May be unrelated to EDT (different code path). |
21 | | -- The separate ParparVM Java test pipelines that were failing in CI (`job-logs2.txt`, `job-logs3.txt`) are now reproduced and fixed locally. |
22 | | - |
23 | | -## Diagnostic Evidence (Updated 2026-04-06) |
24 | | - |
25 | | -After EDT workaround, browser logs show: |
26 | | -``` |
27 | | -PARPAR:DIAG:EDT_ENSURE:reusedMainThread=1 |
28 | | -PARPAR:DIAG:POST_EDT_ENSURE_formCtorTitleLayoutGlobal:displayClassExists=1:instance=present:edt=present:edtThreadName=main |
29 | | -PARPAR:DIAG:PRE_formCtorLayout:displayClassExists=1:instance=present:edt=present:edtThreadName=main |
30 | | -PARPAR:DIAG:ERR_formCtorLayout:displayClassExists=1:instance=present:edt=present:edtThreadName=main |
31 | | -PARPAR:DIAG:FALLBACK:formCtorLayout:bypassIllegalState=1:detail=java_lang_IllegalStateException |
32 | | -``` |
33 | | - |
34 | | -**Key observations**: |
35 | | -- EDT is successfully set (`edt=present:edtThreadName=main`) |
36 | | -- Tests pass (suite completes) |
37 | | -- `IllegalStateException` still triggered but caught by fallback handler |
38 | | -- Exception may originate from code path other than `Display.setCurrent()` EDT check |
39 | | - |
40 | | -## Previous Issues (Historical) |
41 | | - |
42 | | -What Was Fixed In This Round |
43 | | ----------------------------- |
44 | | - |
45 | | -1. **Added EDT initialization workaround** in `port.js`: |
46 | | - - `checkDisplayInitState()` -checks Display.INITANCE and EDT state |
47 | | - - `ensureDisplayEdt()` - creates synthetic EDT thread or reuses main thread |
48 | | - - Form constructor bypasses call `ensureDisplayEdt()` before construction |
49 | | - - Verified workaround works: logs show `EDT_ENSURE:reusedMainThread=1` |
50 | | - |
51 | | -2. **Rebuilt JavaScript bundle** with updated port.js: |
52 | | - - Built with `SKIP_PARPARVM_BUILD=1 ./scripts/build-javascript-port-hellocodenameone.sh` |
53 | | - - Bundle contains updated `port.js` with workaround |
54 | | - |
55 | | -3. **Tests now pass**: |
56 | | - - Suite completes with `CN1SS:SUITE:FINISHED` |
57 | | - - Screenshots generated for MainActivity, graphics-draw-line, graphics-draw-rect, graphics-fill-rect, kotlin |
58 | | - |
59 | | -1. Restored native categorization for JavaScript translation. |
60 | | - - Reintroduced `vm/ByteCodeTranslator/src/com/codename1/tools/translator/JavascriptNativeRegistry.java`. |
61 | | - - Restored registry-driven behavior in `JavascriptMethodGenerator.appendNativeStubIfNeeded(...)`: |
62 | | - - runtime-implemented natives: no generic "Missing javascript native method" stubs. |
63 | | - - host-hook natives: generated `jvm.invokeHostNative(...)` stubs. |
64 | | - - unsupported natives: explicit unsupported error reasons. |
65 | | - |
66 | | -2. Expanded host-hook coverage to the JavaScript port boundary. |
67 | | - - Host-hook prefix now covers `cn1_com_codename1_impl_platform_js_`. |
68 | | - - This fixes `JavaScriptPortHost` bridge symbols used by JavaScript port smoke tests. |
69 | | - |
70 | | -3. Fixed `String.format(...)` runtime coercion bug. |
71 | | - - File: `vm/ByteCodeTranslator/src/javascript/parparvm_runtime.js`. |
72 | | - - Changed format token conversion to use `runtimeFormatTokenValue(...)`. |
73 | | - - This resolves the deterministic `JsJavaApiCoverageApp` mismatch (`expected 511, got 495`; missing bit `16`). |
74 | | - |
75 | | -4. Added explicit PolyForm header text to missing JavaScriptPort boundary files. |
76 | | - - Added `"PolyForm Noncommercial License 1.0.0"` markers to all Java/Markdown files previously flagged by `JavaScriptPortSmokeIntegrationTest`. |
77 | | - |
78 | | -5. Reverted risky JS `INVOKESPECIAL` remap in codegen. |
79 | | - - Removed the recent `Util.resolveInvokeSpecialOwner(...)` injection from JS invoke emission paths for now. |
80 | | - - The broader regressions observed in CI are fixed without that change. |
81 | | - |
82 | | -6. **Enhanced Form constructor error diagnostics**. |
83 | | - - Added `checkDisplayInitState()` function to report Display.INSTANCE and EDT state. |
84 | | - - Added `emitDisplayInitDiag()` calls before and after Form constructor execution. |
85 | | - - Enhanced `stringifyThrowable()` to capture `messageOnly` separately. |
86 | | - - Bypass handlers now log `PRE_` and `ERR_` Display state along with exception details. |
87 | | - |
88 | | -Validated Locally |
89 | | ------------------ |
90 | | - |
91 | | -- `mvn -pl tests -am "-Dtest=JavascriptRuntimeSemanticsTest,JavascriptTargetIntegrationTest,JavaScriptPortSmokeIntegrationTest" -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false test` |
92 | | -- Result: `Tests run: 313, Failures: 0, Errors: 0, Skipped: 0` (BUILD SUCCESS, finished 2026-04-06 10:47:59 +03:00). |
| 11 | +- Startup/protocol is no longer the primary blocker. Main remaining blockers are in screenshot correctness and screenshot pipeline throughput. |
| 12 | +- `ensureDisplayEdt()` and diagnostics remain active in `port.js`. |
| 13 | +- Form constructor `IllegalStateException` bypass now attempts recovery instead of returning `null`: |
| 14 | + - calls default `Form` constructor |
| 15 | + - reapplies layout |
| 16 | + - reapplies title (for title+layout constructor) |
| 17 | + - emits `PARPAR:DIAG:FALLBACK:formCtor*:recoverApplied=1` markers |
| 18 | +- CI artifact behavior and fresh local rebuild behavior are currently diverged (details below). |
93 | 19 |
|
94 | 20 | Next Steps |
95 | 21 | ---------- |
96 | 22 |
|
97 | | -1. **Investigate remaining `IllegalStateException`**: |
98 | | - - Exception occurs even after EDT is set |
99 | | - - May be from different code path (not Display.setCurrent) |
100 | | - - Add exception message logging to `ERR_` diagnostics |
101 | | - |
102 | | -2. **Optional**: Investigate why Display.init() doesn't create EDT in JavaScript port: |
103 | | - - Trace `Display.initNative()` call sequence |
104 | | - - Check if thread creation is happening but not persisting |
105 | | - |
106 | | -3. **Commit workaround**: The `ensureDisplayEdt()` fix allows tests to pass; consider committing as a workaround while root cause is investigated. |
| 23 | +1. Unify build provenance first: |
| 24 | + - Confirm CI bundle contains expected translated `Cn1ssDeviceRunner` variant. |
| 25 | + - In generated `translated_app.js`, verify whether runner uses `TEST_CLASSES` (old list path) or `DEFAULT_TEST_CLASSES/prependedTest` (new array path). |
| 26 | + - This directly changes failure mode and must be deterministic before further triage. |
| 27 | +2. Reduce EDT starvation in screenshot emission: |
| 28 | + - Current fresh local run advances to 11 tests, then stalls after `DrawImage` due very large `CN1SS:<name>:<chunk>` emissions. |
| 29 | + - Add bounded chunk/preview strategy for extremely large screenshots and move heavy conversion off hot EDT path where possible. |
| 30 | +3. Keep form-constructor fallback bounded: |
| 31 | + - `IllegalStateException` still occurs frequently. |
| 32 | + - Recovery now preserves object state better, but we need to reduce recursive/looping constructor retry behavior and make one-shot recovery per form instance. |
| 33 | +4. After throughput fix, run 3 repeated local runs and one CI run: |
| 34 | + - Exit gate is `CN1SS:SUITE:FINISHED` + 33 screenshot streams + no repeated stream collapse. |
107 | 35 |
|
108 | 36 | Important Notes |
109 | 37 | -------------- |
110 | 38 |
|
111 | | -- The CI breakage in the ParparVM Java test pipelines was real and not just screenshot-noise; it is now addressed by the translator/runtime fixes above. |
112 | | -- The screenshot problem remains a separate rendering/lifecycle issue after startup/protocol recovery. |
113 | | -- Error messages are now extracted separately from the full throwable detail for easier parsing. |
| 39 | +- Fresh local rebuild (`/tmp/cn1-js-fresh*.zip`) now translates current runner code and shows 11 unique tests before timeout. |
| 40 | +- Existing CI artifact in `javascript-ui-tests/HelloCodenameOne-js/translated_app.js` still shows old list-based runner (`TEST_CLASSES`) and produces only 5 screenshot streams with suite completion. |
| 41 | +- This means there are at least two active failure modes: |
| 42 | + 1. old-runner path: suite finishes with only 5 streams (wrong collapse) |
| 43 | + 2. new-runner path: progresses further but times out during heavy screenshot emission |
114 | 44 |
|
115 | 45 | Known Important Context |
116 | 46 | ----------------------- |
117 | 47 |
|
118 | | -- This file supersedes older status notes that referenced initial JSBody/static-wrapper bootstrap issues as the primary blocker. |
119 | | -- Current bottleneck is no longer "suite timeout"; it is "suite passes but screenshots are wrong". |
120 | | -- Existing local tree also includes ongoing debug-oriented changes in: |
| 48 | +- Useful diagnostics to grep: |
| 49 | + - `PARPAR:DIAG:FALLBACK:lambdaBridge:capturedTest=...:capturedIndex=...` |
| 50 | + - `PARPAR:DIAG:FALLBACK:formCtorLayout:bypassIllegalState=1` |
| 51 | + - `PARPAR:DIAG:FALLBACK:formCtorLayout:recoverApplied=1` |
| 52 | + - `CN1SS:INFO:suite starting test=...` |
| 53 | + - `CN1SS:SUITE:FINISHED` |
| 54 | +- Current local patch set touches: |
121 | 55 | - `Ports/JavaScriptPort/src/main/webapp/port.js` |
122 | | - - `Ports/JavaScriptPort/src/main/java/com/codename1/impl/html5/HTML5Implementation.java` |
123 | | - These are part of the active CI recovery/debugging workflow. |
| 56 | + - `scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java` |
0 commit comments