@native-sdk/cli 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +26 -9
- package/build.zig +55 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/skill-data/native-ui/SKILL.md +7 -7
- package/skill-data/ts-core/SKILL.md +1 -1
- package/src/app_runner/root.zig +93 -6
- package/src/app_runner/ts_core_main.zig +4 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +192 -40
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +154 -9
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ui_app.zig +9 -3
- package/src/runtime/ui_app_tests.zig +119 -19
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/web_engine.zig +1 -1
|
@@ -651,6 +651,61 @@ test "tree arrow navigation reveals and focuses rows below a scroll viewport" {
|
|
|
651
651
|
try std.testing.expect(scrolled.findById(10).?.widget.value > 0);
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
test "radio-group arrow navigation reveals selects and focuses an offscreen nested radio" {
|
|
655
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
656
|
+
defer harness.destroy(std.testing.allocator);
|
|
657
|
+
harness.null_platform.gpu_surfaces = true;
|
|
658
|
+
var app_state: ObservingApp = .{};
|
|
659
|
+
const app = app_state.app();
|
|
660
|
+
try harness.start(app);
|
|
661
|
+
|
|
662
|
+
_ = try harness.runtime.createView(.{
|
|
663
|
+
.window_id = 1,
|
|
664
|
+
.label = "canvas",
|
|
665
|
+
.kind = .gpu_surface,
|
|
666
|
+
.frame = geometry.RectF.init(0, 0, 240, 64),
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
const radios = [_]canvas.Widget{
|
|
670
|
+
.{ .id = 31, .kind = .radio, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "One", .state = .{ .selected = true } },
|
|
671
|
+
.{ .id = 32, .kind = .radio, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Two" },
|
|
672
|
+
.{ .id = 33, .kind = .radio, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Three" },
|
|
673
|
+
.{ .id = 34, .kind = .radio, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Four" },
|
|
674
|
+
};
|
|
675
|
+
const nested = [_]canvas.Widget{.{
|
|
676
|
+
.kind = .column,
|
|
677
|
+
.layout = .{ .gap = 2 },
|
|
678
|
+
.children = &radios,
|
|
679
|
+
}};
|
|
680
|
+
const group = canvas.Widget{
|
|
681
|
+
.id = 30,
|
|
682
|
+
.kind = .radio_group,
|
|
683
|
+
.frame = geometry.RectF.init(0, 0, 0, 118),
|
|
684
|
+
.children = &nested,
|
|
685
|
+
};
|
|
686
|
+
const root = canvas.Widget{ .id = 20, .kind = .scroll_view, .children = &.{group} };
|
|
687
|
+
var nodes: [10]canvas.WidgetLayoutNode = undefined;
|
|
688
|
+
const layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 64), &nodes);
|
|
689
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
690
|
+
const view = &harness.runtime.views[0];
|
|
691
|
+
view.canvas_widget_focused_id = 31;
|
|
692
|
+
|
|
693
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
694
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
695
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
696
|
+
|
|
697
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 34), view.canvas_widget_focused_id);
|
|
698
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 34), app_state.last_keyboard_target_id);
|
|
699
|
+
try std.testing.expect(app_state.last_keyboard_focus_moved);
|
|
700
|
+
const scrolled = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
701
|
+
const viewport = scrolled.findById(20).?.frame.normalized();
|
|
702
|
+
const focused = scrolled.findById(34).?.frame.normalized();
|
|
703
|
+
try std.testing.expect(focused.y >= viewport.y);
|
|
704
|
+
try std.testing.expect(focused.maxY() <= viewport.maxY());
|
|
705
|
+
try std.testing.expect(!scrolled.findById(31).?.widget.state.selected);
|
|
706
|
+
try std.testing.expect(scrolled.findById(34).?.widget.state.selected);
|
|
707
|
+
}
|
|
708
|
+
|
|
654
709
|
test "list arrow navigation reveals and focuses rows below a scroll viewport" {
|
|
655
710
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
656
711
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -13,6 +13,7 @@ const runtime_canvas_widget_display = @import("canvas_widget_display.zig");
|
|
|
13
13
|
const runtime_view = @import("view.zig");
|
|
14
14
|
const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
|
|
15
15
|
const runtime_automation_widget_dispatch = @import("automation_widget_dispatch.zig");
|
|
16
|
+
const runtime_gpu_surface_events = @import("gpu_surface_events.zig");
|
|
16
17
|
const widget_bridge = @import("widget_bridge.zig");
|
|
17
18
|
|
|
18
19
|
const validateViewLabel = validation.validateViewLabel;
|
|
@@ -119,7 +120,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
119
120
|
// the OS scroller's overscrolled offset instead of clamping it
|
|
120
121
|
// and force-pushing the clamp into the live bounce (visible
|
|
121
122
|
// jitter). Non-driver platforms clamp exactly as before.
|
|
122
|
-
canvas_widget_runtime.
|
|
123
|
+
try canvas_widget_runtime.clampCanvasWidgetLayoutScrollOffsetsAfterReconcile(reconciled_nodes[0..reconciled_layout.nodes.len], null, reconciled_layout.root_bounds, tokens);
|
|
123
124
|
// Runtime-owned tooltip visibility normalizes BEFORE the
|
|
124
125
|
// diff: the retained tree carries the intent machine's
|
|
125
126
|
// hidden stamps on anchored tooltips while the source
|
|
@@ -203,11 +204,20 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
203
204
|
if (render_state_changed) CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetRenderStateDirty(self, index, render_state_dirty);
|
|
204
205
|
const layout_dirty = invalidations.len > 0 or render_state_changed;
|
|
205
206
|
if (autofocus_target) |autofocus_id| {
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
// Autofocus is programmatic, not pointer hit testing: admit a
|
|
208
|
+
// logically focusable target even while a scroll ancestor
|
|
209
|
+
// clips it, then let the shared automation/keyboard reveal
|
|
210
|
+
// seam scroll, reconcile, and re-verify before focus lands.
|
|
211
|
+
// A disabled/hidden/fixed-clipped target still consumes the
|
|
212
|
+
// source edge; holding autofocus true never retries or steals.
|
|
213
|
+
const retained_layout = self.views[index].widgetLayoutTree();
|
|
214
|
+
if (canvas_widget_runtime.canvasWidgetLayoutNodeIndexById(retained_layout, autofocus_id)) |autofocus_index| {
|
|
215
|
+
if (canvas_widget_runtime.canvasWidgetLogicalFocusTarget(retained_layout, autofocus_index) != null) {
|
|
216
|
+
AutomationWidgetMethods(Runtime).focusAutomationCanvasWidget(self, index, autofocus_id) catch |err| switch (err) {
|
|
217
|
+
error.InvalidCommand => {},
|
|
218
|
+
else => return err,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
211
221
|
}
|
|
212
222
|
}
|
|
213
223
|
self.frame_profile.end(.reconcile, reconcile_begin);
|
|
@@ -330,11 +340,27 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
330
340
|
.set_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_set_composition, action.text),
|
|
331
341
|
.commit_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_commit_composition, ""),
|
|
332
342
|
.cancel_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_cancel_composition, ""),
|
|
333
|
-
.select =>
|
|
343
|
+
.select => {
|
|
344
|
+
const node_index = self.views[index].canvasWidgetNodeIndexById(action.id) orelse return error.InvalidCommand;
|
|
345
|
+
if (self.views[index].widget_layout_nodes[node_index].widget.kind == .radio) {
|
|
346
|
+
// Radio selection is activation, not an echo-only
|
|
347
|
+
// retained-state write: drive the same Space path
|
|
348
|
+
// as keyboard and pointer input so a documented
|
|
349
|
+
// `on_change` handler updates the app model too.
|
|
350
|
+
try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, "space");
|
|
351
|
+
} else {
|
|
352
|
+
try AutomationWidgetMethods(Runtime).selectAutomationCanvasWidget(self, index, action.id);
|
|
353
|
+
}
|
|
354
|
+
},
|
|
334
355
|
.drag => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetDrag(self, app, index, action.id, action.text),
|
|
335
356
|
.drop_files => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetFileDrop(self, app, index, action.id, action.text),
|
|
336
357
|
.dismiss => try AutomationWidgetMethods(Runtime).dismissAutomationCanvasWidget(self, app, index, action.id),
|
|
337
358
|
}
|
|
359
|
+
// A direct focus action can reveal an offscreen target without
|
|
360
|
+
// passing through the GPU input dispatcher. Deliver the pending
|
|
361
|
+
// scroll observation in this semantic-action transaction too,
|
|
362
|
+
// rather than leaving it parked until unrelated future input.
|
|
363
|
+
try runtime_gpu_surface_events.RuntimeGpuSurfaceEvents(Runtime).dispatchPendingCanvasWidgetScrollEvents(self, app, index);
|
|
338
364
|
// Key-driven action routes above dispatch real input events
|
|
339
365
|
// whose refresh batches defer the platform publish; the AX
|
|
340
366
|
// client reads the tree next, so force-flush here too.
|
package/src/runtime/core.zig
CHANGED
|
@@ -39,6 +39,7 @@ const bridge = @import("../bridge/root.zig");
|
|
|
39
39
|
const extensions = @import("../extensions/root.zig");
|
|
40
40
|
const app_manifest = @import("app_manifest");
|
|
41
41
|
const platform = @import("../platform/root.zig");
|
|
42
|
+
const window_state = @import("../window_state/root.zig");
|
|
42
43
|
const runtime_effects = @import("effects.zig");
|
|
43
44
|
const runtime_record_store = @import("record_store.zig");
|
|
44
45
|
const runtime_relational_store = @import("relational_store.zig");
|
|
@@ -198,6 +199,10 @@ pub const Runtime = struct {
|
|
|
198
199
|
/// frees, the `deinit` frees) goes through this field, never
|
|
199
200
|
/// through `options.allocator`.
|
|
200
201
|
owned_allocator: std.mem.Allocator,
|
|
202
|
+
/// Registered-image budget captured at init. Decode, registration,
|
|
203
|
+
/// replay validation, slot reuse, and deinit all observe this one
|
|
204
|
+
/// app-fixed limit even if public `options` is later mutated.
|
|
205
|
+
max_image_pixel_bytes: usize = canvas_limits.max_registered_canvas_image_pixel_bytes,
|
|
201
206
|
surface: platform.Surface,
|
|
202
207
|
appearance: platform.Appearance = .{},
|
|
203
208
|
windows: [platform.max_windows]RuntimeWindow = undefined,
|
|
@@ -253,6 +258,11 @@ pub const Runtime = struct {
|
|
|
253
258
|
video_height: u64 = 0,
|
|
254
259
|
shell_layouts: [platform.max_windows]RuntimeShellLayout = undefined,
|
|
255
260
|
shell_layout_count: usize = 0,
|
|
261
|
+
/// Reused by runtime-created window restoration. `Store.loadWindow`
|
|
262
|
+
/// needs the whole bounded state file plus decoded-string scratch; keep
|
|
263
|
+
/// that 64-KiB workspace on the already heap-owned Runtime instead of
|
|
264
|
+
/// placing it on the event-loop stack for every secondary-window create.
|
|
265
|
+
window_state_read_scratch: [window_state.max_serialized_bytes]u8 = undefined,
|
|
256
266
|
next_window_id: platform.WindowId = 2,
|
|
257
267
|
next_view_id: platform.ViewId = 1,
|
|
258
268
|
invalidated: bool = true,
|
|
@@ -499,10 +509,16 @@ pub const Runtime = struct {
|
|
|
499
509
|
}
|
|
500
510
|
}
|
|
501
511
|
self.options = options;
|
|
512
|
+
if (options.max_image_pixel_bytes < canvas_limits.max_registered_canvas_image_pixel_bytes or
|
|
513
|
+
options.max_image_pixel_bytes > canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling)
|
|
514
|
+
{
|
|
515
|
+
@panic("max_image_pixel_bytes must be between 1 MiB and 8 MiB; declare app.zon .images.max_image_pixel_bytes within that range");
|
|
516
|
+
}
|
|
502
517
|
// Freeze the ownership allocator now (see the field doc):
|
|
503
518
|
// `options` stays publicly mutable, but the identity that owns
|
|
504
519
|
// on-demand storage must not move under live allocations.
|
|
505
520
|
self.owned_allocator = options.allocator;
|
|
521
|
+
self.max_image_pixel_bytes = options.max_image_pixel_bytes;
|
|
506
522
|
self.surface = options.platform.surface();
|
|
507
523
|
// The profile rings exceed the small-default copy bound above;
|
|
508
524
|
// assign explicitly so the disabled state is never undefined.
|
package/src/runtime/effects.zig
CHANGED
|
@@ -977,17 +977,16 @@ pub fn imageCachePartialPath(buffer: []u8, cache_path: []const u8, generation: u
|
|
|
977
977
|
/// `.rejected` image result Msg.
|
|
978
978
|
pub const max_effect_image_path_bytes: usize = max_effect_file_path_bytes;
|
|
979
979
|
|
|
980
|
-
/// Maximum ENCODED source bytes one `loadImage` accepts —
|
|
981
|
-
///
|
|
982
|
-
///
|
|
983
|
-
///
|
|
984
|
-
///
|
|
985
|
-
///
|
|
986
|
-
///
|
|
987
|
-
///
|
|
988
|
-
|
|
989
|
-
pub const max_effect_image_bytes: usize =
|
|
990
|
-
canvas_limits.max_registered_canvas_image_pixel_bytes / 4;
|
|
980
|
+
/// Maximum ENCODED source bytes one `loadImage` accepts — independent of
|
|
981
|
+
/// the decoded-pixel target now that codecs decode-to-fit. Eight MiB covers
|
|
982
|
+
/// typical phone JPEG/HEIC photos while keeping costs fixed and loud: every
|
|
983
|
+
/// in-flight load owns a transient `bound + 1` fetch/read buffer, recorded
|
|
984
|
+
/// source bytes grow the session blob store, and URL cache entries may reach
|
|
985
|
+
/// this size. Unlike fetch bodies there is no truncated delivery — a cut
|
|
986
|
+
/// image can never decode, so over-bound sources fail whole with
|
|
987
|
+
/// `.too_large`. The bound stays flat when an app raises its pixel budget.
|
|
988
|
+
pub const max_effect_image_source_bytes: usize = 8 * 1024 * 1024;
|
|
989
|
+
pub const max_effect_image_bytes: usize = max_effect_image_source_bytes;
|
|
991
990
|
|
|
992
991
|
/// Bytes of an image effect result's content address in the session
|
|
993
992
|
/// journal: the first half of the source bytes' SHA-256, the
|
|
@@ -1031,9 +1030,10 @@ pub const EffectImageOutcome = enum(u8) {
|
|
|
1031
1030
|
http_status,
|
|
1032
1031
|
/// `cancel(id)` ended the load before its result was delivered.
|
|
1033
1032
|
cancelled,
|
|
1034
|
-
/// The source bytes exceed `
|
|
1035
|
-
/// pixels
|
|
1036
|
-
///
|
|
1033
|
+
/// The source bytes exceed `max_effect_image_source_bytes`. A conforming
|
|
1034
|
+
/// codec fits decoded pixels to the app's registered-image budget;
|
|
1035
|
+
/// `error.ImageTooLarge` is retained only as a defensive codec-contract
|
|
1036
|
+
/// violation and maps here too.
|
|
1037
1037
|
too_large,
|
|
1038
1038
|
/// The host has no image codec (`error.UnsupportedService`), or no
|
|
1039
1039
|
/// image registry is bound to this channel.
|
|
@@ -294,6 +294,97 @@ test "fake executor records the whole load request shape and feeds bytes through
|
|
|
294
294
|
try std.testing.expectEqual(@as(usize, 1), h.app_state.effects.pendingImageLoadCount());
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
test "photo-scale feed decodes to fit and reports registered geometry" {
|
|
298
|
+
var h = try Harness.create();
|
|
299
|
+
defer h.destroy();
|
|
300
|
+
h.app_state.effects.executor = .fake;
|
|
301
|
+
test_path = "assets/photo.png";
|
|
302
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
303
|
+
|
|
304
|
+
const width: usize = 640;
|
|
305
|
+
const height: usize = 480;
|
|
306
|
+
const pixels = try std.testing.allocator.alloc(u8, width * height * 4);
|
|
307
|
+
defer std.testing.allocator.free(pixels);
|
|
308
|
+
var index: usize = 0;
|
|
309
|
+
while (index < pixels.len) : (index += 4) pixels[index..][0..4].* = .{ 24, 88, 176, 255 };
|
|
310
|
+
const encoded_len = try canvas.png.encodedRgba8ByteLen(width, height);
|
|
311
|
+
const encoded_buffer = try std.testing.allocator.alloc(u8, encoded_len);
|
|
312
|
+
defer std.testing.allocator.free(encoded_buffer);
|
|
313
|
+
var writer = std.Io.Writer.fixed(encoded_buffer);
|
|
314
|
+
try canvas.png.writeRgba8(&writer, width, height, pixels);
|
|
315
|
+
|
|
316
|
+
try h.app_state.effects.feedImageBytes(image_id, writer.buffered());
|
|
317
|
+
try h.drainWakes();
|
|
318
|
+
const result = h.app_state.model.last.?;
|
|
319
|
+
try std.testing.expectEqual(effects_mod.EffectImageOutcome.loaded, result.outcome);
|
|
320
|
+
try std.testing.expectEqual(@as(usize, 591), result.width);
|
|
321
|
+
try std.testing.expectEqual(@as(usize, 443), result.height);
|
|
322
|
+
try std.testing.expect(result.width * result.height * 4 <= h.harness.runtime.max_image_pixel_bytes);
|
|
323
|
+
try std.testing.expectApproxEqAbs(@as(f64, 4.0 / 3.0), @as(f64, @floatFromInt(result.width)) / @as(f64, @floatFromInt(result.height)), 0.01);
|
|
324
|
+
const registered = h.harness.runtime.registeredCanvasImage(image_id).?;
|
|
325
|
+
try std.testing.expectEqual(result.width, registered.width);
|
|
326
|
+
try std.testing.expectEqual(result.height, registered.height);
|
|
327
|
+
try std.testing.expectEqualSlices(u8, &[_]u8{ 24, 88, 176, 255 }, h.harness.runtime.registeredCanvasImages()[0].pixels[0..4]);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
test "raised image budget loads a 1080p source without downscaling" {
|
|
331
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
332
|
+
defer harness.destroy(std.testing.allocator);
|
|
333
|
+
harness.null_platform.gpu_surfaces = true;
|
|
334
|
+
harness.null_platform.image_decode = true;
|
|
335
|
+
core.Runtime.initAt(&harness.runtime, .{
|
|
336
|
+
.platform = harness.null_platform.platform(),
|
|
337
|
+
.trace_sink = harness.trace_sink.sink(),
|
|
338
|
+
.max_image_pixel_bytes = canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling,
|
|
339
|
+
.environ = std.testing.environ,
|
|
340
|
+
});
|
|
341
|
+
harness.runtime.dispatch_error_policy = .propagate;
|
|
342
|
+
|
|
343
|
+
const app_state = try std.testing.allocator.create(ImageApp);
|
|
344
|
+
defer std.testing.allocator.destroy(app_state);
|
|
345
|
+
app_state.* = ImageApp.init(std.heap.page_allocator, .{}, .{
|
|
346
|
+
.name = "effects-image-raised-budget",
|
|
347
|
+
.scene = image_scene,
|
|
348
|
+
.canvas_label = canvas_label,
|
|
349
|
+
.update_fx = imageUpdate,
|
|
350
|
+
.view = imageView,
|
|
351
|
+
});
|
|
352
|
+
defer app_state.deinit();
|
|
353
|
+
app_state.effects.executor = .fake;
|
|
354
|
+
const app = app_state.app();
|
|
355
|
+
try harness.start(app);
|
|
356
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
357
|
+
.label = canvas_label,
|
|
358
|
+
.size = geometry.SizeF.init(400, 300),
|
|
359
|
+
.scale_factor = 1,
|
|
360
|
+
.frame_index = 1,
|
|
361
|
+
.timestamp_ns = 1_000_000,
|
|
362
|
+
.nonblank = true,
|
|
363
|
+
} });
|
|
364
|
+
|
|
365
|
+
test_path = "assets/wallpaper.png";
|
|
366
|
+
try app_state.dispatch(&harness.runtime, 1, .start);
|
|
367
|
+
const width: usize = 1920;
|
|
368
|
+
const height: usize = 1080;
|
|
369
|
+
const pixels = try std.testing.allocator.alloc(u8, width * height * 4);
|
|
370
|
+
defer std.testing.allocator.free(pixels);
|
|
371
|
+
@memset(pixels, 0x6D);
|
|
372
|
+
const encoded_len = try canvas.png.encodedRgba8ByteLen(width, height);
|
|
373
|
+
try std.testing.expect(encoded_len <= effects_mod.max_effect_image_source_bytes);
|
|
374
|
+
const encoded = try std.testing.allocator.alloc(u8, encoded_len);
|
|
375
|
+
defer std.testing.allocator.free(encoded);
|
|
376
|
+
var writer = std.Io.Writer.fixed(encoded);
|
|
377
|
+
try canvas.png.writeRgba8(&writer, width, height, pixels);
|
|
378
|
+
try app_state.effects.feedImageBytes(image_id, writer.buffered());
|
|
379
|
+
try harness.runtime.dispatchPlatformEvent(app, .wake);
|
|
380
|
+
|
|
381
|
+
const result = app_state.model.last.?;
|
|
382
|
+
try std.testing.expectEqual(effects_mod.EffectImageOutcome.loaded, result.outcome);
|
|
383
|
+
try std.testing.expectEqual(width, result.width);
|
|
384
|
+
try std.testing.expectEqual(height, result.height);
|
|
385
|
+
try std.testing.expectEqual(width, harness.runtime.registeredCanvasImage(image_id).?.width);
|
|
386
|
+
}
|
|
387
|
+
|
|
297
388
|
test "undecodable and oversized feeds fail with the registry's own classes" {
|
|
298
389
|
var h = try Harness.create();
|
|
299
390
|
defer h.destroy();
|
|
@@ -9,6 +9,7 @@ const runtime_canvas_widget_context_menu = @import("canvas_widget_context_menu.z
|
|
|
9
9
|
const runtime_canvas_widget_display = @import("canvas_widget_display.zig");
|
|
10
10
|
const runtime_canvas_widget_events = @import("canvas_widget_events.zig");
|
|
11
11
|
const runtime_canvas_widget_scroll_drivers = @import("canvas_widget_scroll_drivers.zig");
|
|
12
|
+
const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
12
13
|
|
|
13
14
|
const canvasWidgetInputBatchesDisplayListRefresh = canvas_frame_helpers.canvasWidgetInputBatchesDisplayListRefresh;
|
|
14
15
|
const gpuSurfaceFrameEventFromGpuFrame = canvas_frame_helpers.gpuSurfaceFrameEventFromGpuFrame;
|
|
@@ -361,7 +362,7 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
361
362
|
// activation (checkbox/toggle state), not only app Msgs and
|
|
362
363
|
// commands. Geometry controls applied their live resize on
|
|
363
364
|
// move; a terminal drag owes no release mutation.
|
|
364
|
-
if (!widget_drag_terminal) try CanvasWidgetEventMethods().updateCanvasWidgetControlFromPointer(self, pointer_event
|
|
365
|
+
if (!widget_drag_terminal) try CanvasWidgetEventMethods().updateCanvasWidgetControlFromPointer(self, pointer_event);
|
|
365
366
|
try CanvasWidgetEventMethods().updateCanvasWidgetInteractionFromPointer(self, pointer_event.*);
|
|
366
367
|
// The text pass may stamp a caret/selection or clear
|
|
367
368
|
// edit onto the event for the app dispatch below.
|
|
@@ -448,6 +449,28 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
448
449
|
// from "an arrow landed here in place".
|
|
449
450
|
if (widget_keyboard_event) |*keyboard_event| {
|
|
450
451
|
keyboard_event.keyboard.focus_moved = widget_focus_moved;
|
|
452
|
+
// Nearest-radio-group navigation owns its key even when
|
|
453
|
+
// Home/End names the current edge or a one-member group
|
|
454
|
+
// wraps in place. Selection is a separate stamp: a real
|
|
455
|
+
// focus move selects the landed radio, and an in-place
|
|
456
|
+
// move selects only an unchecked current radio. Bare
|
|
457
|
+
// radios preserve their legacy focus-only spatial
|
|
458
|
+
// behavior, and Tab entry never synthesizes a selection.
|
|
459
|
+
const view_index = runtimeFindViewIndex(self, input_event.window_id, input_event.label).?;
|
|
460
|
+
const layout = self.views[view_index].widgetLayoutTree();
|
|
461
|
+
const radio_group_navigation = navigation: {
|
|
462
|
+
const target = keyboard_event.target orelse break :navigation false;
|
|
463
|
+
if (target.kind != .radio) break :navigation false;
|
|
464
|
+
if (canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(layout, target.index) == null) break :navigation false;
|
|
465
|
+
break :navigation canvas_widget_runtime.canvasWidgetGroupFocusEdgeFromInput(input_event) != null or
|
|
466
|
+
canvas_widget_runtime.canvasWidgetSpatialFocusDirection(input_event) != null;
|
|
467
|
+
};
|
|
468
|
+
keyboard_event.keyboard.radio_group_navigation = radio_group_navigation;
|
|
469
|
+
if (radio_group_navigation) {
|
|
470
|
+
const target = keyboard_event.target.?;
|
|
471
|
+
keyboard_event.keyboard.radio_group_selection = widget_focus_moved or
|
|
472
|
+
!canvas_widget_runtime.canvasWidgetSelectableSelected(layout.nodes[target.index].widget);
|
|
473
|
+
}
|
|
451
474
|
}
|
|
452
475
|
// Clipboard shortcuts resolve against the raw input (copy has
|
|
453
476
|
// no routed target when a static text selection is live) and
|
|
@@ -471,7 +494,7 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
471
494
|
// armed/shown tooltip before the control mutation and
|
|
472
495
|
// app dispatch observe the input.
|
|
473
496
|
try CanvasWidgetEventMethods().updateCanvasTooltipIntentForKeyboardActivation(self, keyboard_event.*);
|
|
474
|
-
try CanvasWidgetEventMethods().updateCanvasWidgetControlFromKeyboard(self, keyboard_event
|
|
497
|
+
try CanvasWidgetEventMethods().updateCanvasWidgetControlFromKeyboard(self, keyboard_event);
|
|
475
498
|
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, keyboard_event);
|
|
476
499
|
}
|
|
477
500
|
// An IME sequence belongs to whoever it STARTED over: a
|
package/src/runtime/root.zig
CHANGED
|
@@ -143,6 +143,7 @@ pub const EffectImageOutcome = runtime_effects.EffectImageOutcome;
|
|
|
143
143
|
pub const imageCachePath = runtime_effects.imageCachePath;
|
|
144
144
|
pub const max_effect_image_path_bytes = runtime_effects.max_effect_image_path_bytes;
|
|
145
145
|
pub const max_effect_image_bytes = runtime_effects.max_effect_image_bytes;
|
|
146
|
+
pub const max_effect_image_source_bytes = runtime_effects.max_effect_image_source_bytes;
|
|
146
147
|
pub const effect_image_blob_hash_len = runtime_effects.effect_image_blob_hash_len;
|
|
147
148
|
pub const EffectChannelEvent = runtime_effects.EffectChannelEvent;
|
|
148
149
|
pub const EffectChannelEventKind = runtime_effects.EffectChannelEventKind;
|
|
@@ -246,6 +247,7 @@ const runtime_canvas_images = @import("canvas_images.zig");
|
|
|
246
247
|
pub const RegisteredCanvasImage = runtime_canvas_images.RegisteredCanvasImage;
|
|
247
248
|
pub const max_registered_canvas_images = runtime_canvas_images.max_registered_canvas_images;
|
|
248
249
|
pub const max_registered_canvas_image_pixel_bytes = runtime_canvas_images.max_registered_canvas_image_pixel_bytes;
|
|
250
|
+
pub const max_registered_canvas_image_pixel_bytes_ceiling = runtime_canvas_images.max_registered_canvas_image_pixel_bytes_ceiling;
|
|
249
251
|
|
|
250
252
|
// The media-surface producer channel (media_surface.zig): the handle
|
|
251
253
|
// type `Runtime.acquireMediaSurfaceProducer` returns rides the public
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
|
|
29
29
|
const std = @import("std");
|
|
30
30
|
const canvas = @import("canvas");
|
|
31
|
-
const canvas_limits = @import("canvas_limits.zig");
|
|
32
31
|
const automation_protocol = @import("../automation/protocol.zig");
|
|
32
|
+
const canvas_limits = @import("canvas_limits.zig");
|
|
33
33
|
const core = @import("core.zig");
|
|
34
34
|
const journal = @import("session_journal.zig");
|
|
35
|
+
const platform = @import("../platform/root.zig");
|
|
35
36
|
const runtime_effects = @import("effects.zig");
|
|
36
37
|
const session_blobs = @import("session_blobs.zig");
|
|
37
38
|
|
|
@@ -58,8 +59,8 @@ pub const ReplayError = error{
|
|
|
58
59
|
/// can never produce (an image record claiming `.loaded` with a
|
|
59
60
|
/// zero-length blob: the recorder journals `.loaded` only after the
|
|
60
61
|
/// bytes decoded and registered, and empty bytes cannot decode; or
|
|
61
|
-
/// decoded dimensions
|
|
62
|
-
/// — zero or over
|
|
62
|
+
/// decoded dimensions no conforming recording could have accepted
|
|
63
|
+
/// — zero or over the SDK hard ceiling on `.loaded`, nonzero on any other
|
|
63
64
|
/// outcome) — the journal is damaged or hand-edited.
|
|
64
65
|
/// `JournalCorrupt` is the structural sibling (payloads that fail
|
|
65
66
|
/// to decode at all); this class is for records that decode fine
|
|
@@ -206,9 +207,8 @@ pub fn replaySession(
|
|
|
206
207
|
// Decoded dimensions obey the recorder the same way: a
|
|
207
208
|
// live `.loaded` journals only after the canvas registry
|
|
208
209
|
// accepted the pixels (nonzero width and height, and
|
|
209
|
-
// width * height * 4 bytes within
|
|
210
|
-
//
|
|
211
|
-
// bound `registerCanvasImage` enforces), and every other
|
|
210
|
+
// width * height * 4 bytes within that recording's
|
|
211
|
+
// runtime-frozen app image budget), and every other
|
|
212
212
|
// outcome journals 0x0. Refuse out-of-bound dims HERE:
|
|
213
213
|
// the fed values flow verbatim into the app's Msg — and,
|
|
214
214
|
// on the TS core host, through `@intCast` into
|
|
@@ -251,7 +251,7 @@ pub fn replaySession(
|
|
|
251
251
|
}
|
|
252
252
|
if (effect.kind == .image and imageDimsDamaged(effect)) {
|
|
253
253
|
std.debug.print(
|
|
254
|
-
"replay refused after event {d}: image record for id {d} claims .{s} with dimensions {d}x{d} - a recorded .loaded always carries nonzero decoded dimensions within the registered-image
|
|
254
|
+
"replay refused after event {d}: image record for id {d} claims .{s} with dimensions {d}x{d} - a recorded .loaded always carries nonzero decoded dimensions within the SDK's registered-image ceiling and every other outcome records 0x0, so the journal is damaged or hand-edited; re-record the session\n",
|
|
255
255
|
.{ report.events_replayed, effect.key, @tagName(effect.image_outcome), effect.image_width, effect.image_height },
|
|
256
256
|
);
|
|
257
257
|
return error.ReplayDamagedRecord;
|
|
@@ -753,9 +753,14 @@ fn imageDimsDamaged(record: journal.EffectResultRecord) bool {
|
|
|
753
753
|
return record.image_width != 0 or record.image_height != 0;
|
|
754
754
|
}
|
|
755
755
|
if (record.image_width == 0 or record.image_height == 0) return true;
|
|
756
|
+
if (record.image_width > platform.max_decoded_image_dimension or record.image_height > platform.max_decoded_image_dimension) return true;
|
|
756
757
|
const pixels = std.math.mul(u64, record.image_width, record.image_height) catch return true;
|
|
757
758
|
const pixel_bytes = std.math.mul(u64, pixels, 4) catch return true;
|
|
758
|
-
|
|
759
|
+
// The journal does not carry the recording's manifest budget. Validate
|
|
760
|
+
// against the SDK-wide ceiling: a result above the replay runtime's
|
|
761
|
+
// current (possibly lowered) budget is still valid recorder truth. Its
|
|
762
|
+
// Msg feeds verbatim; best-effort pixel re-registration may fit smaller.
|
|
763
|
+
return pixel_bytes > canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling;
|
|
759
764
|
}
|
|
760
765
|
|
|
761
766
|
/// Journaled results that regenerate deterministically from the
|
|
@@ -12,6 +12,7 @@ const app_manifest = @import("app_manifest");
|
|
|
12
12
|
const core = @import("core.zig");
|
|
13
13
|
const ui_app_mod = @import("ui_app.zig");
|
|
14
14
|
const effects_mod = @import("effects.zig");
|
|
15
|
+
const canvas_limits = @import("canvas_limits.zig");
|
|
15
16
|
const platform = @import("../platform/root.zig");
|
|
16
17
|
const journal = @import("session_journal.zig");
|
|
17
18
|
const session_record = @import("session_record.zig");
|
|
@@ -1788,6 +1789,104 @@ test "image loads record into the blob store (deduplicated) and replay byte-iden
|
|
|
1788
1789
|
try std.testing.expect(harness.runtime.registeredCanvasImage(23) == null);
|
|
1789
1790
|
}
|
|
1790
1791
|
|
|
1792
|
+
test "raised-budget photo load replays recorded dimensions under a smaller current budget" {
|
|
1793
|
+
const gpa = std.testing.allocator;
|
|
1794
|
+
const buffer = try std.heap.page_allocator.create(JournalBuffer);
|
|
1795
|
+
defer std.heap.page_allocator.destroy(buffer);
|
|
1796
|
+
buffer.len = 0;
|
|
1797
|
+
var store = session_blobs.MemoryBlobStore.init(gpa);
|
|
1798
|
+
defer store.deinit();
|
|
1799
|
+
|
|
1800
|
+
const recorder = try std.heap.page_allocator.create(session_record.SessionRecorder);
|
|
1801
|
+
defer std.heap.page_allocator.destroy(recorder);
|
|
1802
|
+
recorder.* = session_record.SessionRecorder.init(buffer.sink());
|
|
1803
|
+
recorder.blob_sink = store.sink();
|
|
1804
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "image-session-demo", .window_width = 400, .window_height = 300 });
|
|
1805
|
+
|
|
1806
|
+
const record_harness = try core.TestHarness().create(gpa, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1807
|
+
defer record_harness.destroy(gpa);
|
|
1808
|
+
record_harness.null_platform.gpu_surfaces = true;
|
|
1809
|
+
record_harness.null_platform.image_decode = true;
|
|
1810
|
+
core.Runtime.initAt(&record_harness.runtime, .{
|
|
1811
|
+
.platform = record_harness.null_platform.platform(),
|
|
1812
|
+
.trace_sink = record_harness.trace_sink.sink(),
|
|
1813
|
+
.max_image_pixel_bytes = canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling,
|
|
1814
|
+
.environ = std.testing.environ,
|
|
1815
|
+
.session_recorder = recorder,
|
|
1816
|
+
});
|
|
1817
|
+
record_harness.runtime.dispatch_error_policy = .propagate;
|
|
1818
|
+
|
|
1819
|
+
const record_app = try gpa.create(ImageSessionApp);
|
|
1820
|
+
defer gpa.destroy(record_app);
|
|
1821
|
+
record_app.* = ImageSessionApp.init(std.heap.page_allocator, .{}, imageSessionOptions());
|
|
1822
|
+
defer record_app.deinit();
|
|
1823
|
+
record_app.effects.executor = .fake;
|
|
1824
|
+
const record_runtime_app = record_app.app();
|
|
1825
|
+
try record_harness.start(record_runtime_app);
|
|
1826
|
+
try record_harness.runtime.dispatchPlatformEvent(record_runtime_app, .{ .gpu_surface_frame = .{
|
|
1827
|
+
.label = image_canvas_label,
|
|
1828
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1829
|
+
.scale_factor = 1,
|
|
1830
|
+
.frame_index = 1,
|
|
1831
|
+
.timestamp_ns = 1_000_000,
|
|
1832
|
+
} });
|
|
1833
|
+
|
|
1834
|
+
const width: usize = 640;
|
|
1835
|
+
const height: usize = 480;
|
|
1836
|
+
const pixels = try gpa.alloc(u8, width * height * 4);
|
|
1837
|
+
defer gpa.free(pixels);
|
|
1838
|
+
var pixel_offset: usize = 0;
|
|
1839
|
+
while (pixel_offset < pixels.len) : (pixel_offset += 4) pixels[pixel_offset..][0..4].* = .{ 31, 97, 211, 255 };
|
|
1840
|
+
const encoded_len = try canvas.png.encodedRgba8ByteLen(width, height);
|
|
1841
|
+
const encoded = try gpa.alloc(u8, encoded_len);
|
|
1842
|
+
defer gpa.free(encoded);
|
|
1843
|
+
var writer = std.Io.Writer.fixed(encoded);
|
|
1844
|
+
try canvas.png.writeRgba8(&writer, width, height, pixels);
|
|
1845
|
+
|
|
1846
|
+
try record_harness.runtime.dispatchPlatformEvent(record_runtime_app, .{ .menu_command = .{ .name = "image.cover", .window_id = 1 } });
|
|
1847
|
+
try record_app.effects.feedImageBytes(21, writer.buffered());
|
|
1848
|
+
try record_harness.runtime.dispatchPlatformEvent(record_runtime_app, .wake);
|
|
1849
|
+
try record_harness.runtime.dispatchPlatformEvent(record_runtime_app, .frame_requested);
|
|
1850
|
+
const recorded_model = record_app.model;
|
|
1851
|
+
const recorded_fingerprint = record_harness.runtime.sessionStateFingerprint();
|
|
1852
|
+
const recorded_pixels = record_harness.runtime.registeredCanvasImages()[0].pixels;
|
|
1853
|
+
const recorded_pixel_len = recorded_pixels.len;
|
|
1854
|
+
try std.testing.expectEqual(width, recorded_model.last_width);
|
|
1855
|
+
try std.testing.expectEqual(height, recorded_model.last_height);
|
|
1856
|
+
recorder.finish();
|
|
1857
|
+
try std.testing.expect(!recorder.failed);
|
|
1858
|
+
|
|
1859
|
+
const replay_harness = try core.TestHarness().create(gpa, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1860
|
+
defer replay_harness.destroy(gpa);
|
|
1861
|
+
replay_harness.null_platform.gpu_surfaces = true;
|
|
1862
|
+
core.Runtime.initAt(&replay_harness.runtime, .{
|
|
1863
|
+
.platform = replay_harness.null_platform.platform(),
|
|
1864
|
+
.trace_sink = replay_harness.trace_sink.sink(),
|
|
1865
|
+
.environ = std.testing.environ,
|
|
1866
|
+
});
|
|
1867
|
+
replay_harness.runtime.dispatch_error_policy = .propagate;
|
|
1868
|
+
platform.installHeadlessImageCodec("null", &replay_harness.null_platform, &replay_harness.runtime.options.platform.services);
|
|
1869
|
+
const replay_app = try gpa.create(ImageSessionApp);
|
|
1870
|
+
defer gpa.destroy(replay_app);
|
|
1871
|
+
replay_app.* = ImageSessionApp.init(std.heap.page_allocator, .{}, imageSessionOptions());
|
|
1872
|
+
defer replay_app.deinit();
|
|
1873
|
+
|
|
1874
|
+
const report = try session_replay.replaySession(&replay_harness.runtime, replay_app.app(), buffer.journalBytes(), .{
|
|
1875
|
+
.verify = true,
|
|
1876
|
+
.require_same_platform = false,
|
|
1877
|
+
.blobs = store.source(),
|
|
1878
|
+
});
|
|
1879
|
+
try std.testing.expect(report.ok());
|
|
1880
|
+
try std.testing.expectEqualDeep(recorded_model, replay_app.model);
|
|
1881
|
+
try std.testing.expectEqual(recorded_fingerprint, replay_harness.runtime.sessionStateFingerprint());
|
|
1882
|
+
const replay_info = replay_harness.runtime.registeredCanvasImage(21).?;
|
|
1883
|
+
try std.testing.expectEqual(recorded_model.last_width, replay_app.model.last_width);
|
|
1884
|
+
try std.testing.expectEqual(recorded_model.last_height, replay_app.model.last_height);
|
|
1885
|
+
try std.testing.expect(replay_info.width * replay_info.height * 4 <= replay_harness.runtime.max_image_pixel_bytes);
|
|
1886
|
+
try std.testing.expect(replay_info.width < width or replay_info.height < height);
|
|
1887
|
+
try std.testing.expect(recorded_pixel_len != replay_harness.runtime.registeredCanvasImages()[0].pixels.len);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1791
1890
|
/// Record the undelivered-window reference session: load id 21, feed
|
|
1792
1891
|
/// its bytes (terminal queued, slot `.draining`, delivery still
|
|
1793
1892
|
/// ahead), then — before any drain — an UNRELATED dispatch loads id
|
|
@@ -3080,10 +3179,18 @@ test "an image record claiming dimensions on a non-loaded outcome refuses replay
|
|
|
3080
3179
|
try std.testing.expectError(error.ReplayDamagedRecord, result);
|
|
3081
3180
|
}
|
|
3082
3181
|
|
|
3083
|
-
test "an image record claiming .loaded past the
|
|
3084
|
-
//
|
|
3085
|
-
//
|
|
3086
|
-
const result = replayWithPatchedImageDims(.loaded,
|
|
3182
|
+
test "an image record claiming .loaded past the SDK ceiling refuses replay as damage" {
|
|
3183
|
+
// 2048x2048 RGBA8 is 16 MiB - past the largest registered-image slot
|
|
3184
|
+
// any conforming recording can accept.
|
|
3185
|
+
const result = replayWithPatchedImageDims(.loaded, 2048, 2048);
|
|
3186
|
+
try std.testing.expectError(error.ReplayDamagedRecord, result);
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
test "an image record claiming .loaded past the decoded-axis ceiling refuses replay as damage" {
|
|
3190
|
+
// Source metadata may exceed this ceiling, but every conforming host fits
|
|
3191
|
+
// it before registration and therefore before these result dimensions are
|
|
3192
|
+
// journaled.
|
|
3193
|
+
const result = replayWithPatchedImageDims(.loaded, platform.max_decoded_image_dimension + 1, 1);
|
|
3087
3194
|
try std.testing.expectError(error.ReplayDamagedRecord, result);
|
|
3088
3195
|
}
|
|
3089
3196
|
|
|
@@ -278,6 +278,18 @@ test "runtime materializes manifest shell windows into laid out views" {
|
|
|
278
278
|
const window = try harness.runtime.createShellWindow(shell_window, platform.WebViewSource.html("<h1>Shell</h1>"));
|
|
279
279
|
try std.testing.expectEqual(@as(platform.WindowId, 2), window.id);
|
|
280
280
|
try std.testing.expectEqualStrings("shell", window.label);
|
|
281
|
+
try std.testing.expectEqual(platform.WindowInitialPlacement.default, harness.null_platform.window_placement[1]);
|
|
282
|
+
try std.testing.expectEqual(platform.WindowRestorePolicy.center_on_primary, harness.null_platform.window_restore_policy[1]);
|
|
283
|
+
|
|
284
|
+
const positioned = try harness.runtime.createShellWindow(.{
|
|
285
|
+
.label = "positioned",
|
|
286
|
+
.x = 96,
|
|
287
|
+
.y = 144,
|
|
288
|
+
.views = &.{},
|
|
289
|
+
}, platform.WebViewSource.html("<h1>Positioned</h1>"));
|
|
290
|
+
try std.testing.expectEqual(@as(f32, 96), positioned.frame.x);
|
|
291
|
+
try std.testing.expectEqual(@as(f32, 144), positioned.frame.y);
|
|
292
|
+
try std.testing.expectEqual(platform.WindowInitialPlacement.explicit, harness.null_platform.window_placement[2]);
|
|
281
293
|
|
|
282
294
|
var views_buffer: [13]platform.ViewInfo = undefined;
|
|
283
295
|
const views = harness.runtime.listViews(window.id, &views_buffer);
|