Skip to content

Commit de841e7

Browse files
committed
debug: Add comprehensive channel and state logging
Add detailed debug logging to track all channel operations and state changes in the webgpu-cube example. This will help diagnose why the auto-rotate state isn't updating when the toggle button is clicked. Logging added for: - Initial state send in App constructor - Command reception and processing - State changes (autoRotate, speed, rotation) - State updates sent to controlState channel - Controls component state reception - Button click events - Render cycles with current state - app.Update() calls All logs prefixed with component/operation for easy filtering: - [Goroutine] - goroutine lifecycle - [Command] - command details - [State Change] - variable updates - [State Send] - state sent to channel - [State Receive] - state received from channel - [Controls] - Controls component operations - [Controls.Render] - render cycle info This will help identify if: 1. Commands are being received 2. State is being updated 3. State updates are being sent 4. Controls is receiving updates 5. Re-renders are being triggered
1 parent bd8e648 commit de841e7

3 files changed

Lines changed: 61 additions & 2 deletions

File tree

examples/webgpu-cube/app_gen.go

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/webgpu-cube/controls_gen.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build js && wasm
2+
3+
package main
4+
5+
import "fmt"
6+
7+
func logCommand(cmd ControlCommand) {
8+
log(fmt.Sprintf("[Command] Type: %s, Value: %f", cmd.Type, cmd.Value))
9+
}
10+
11+
func logStateChange(field string, oldVal, newVal interface{}) {
12+
log(fmt.Sprintf("[State Change] %s: %v -> %v", field, oldVal, newVal))
13+
}
14+
15+
func logStateSend(state ControlState) {
16+
log(fmt.Sprintf("[State Send] AutoRotate: %t, Speed: %f", state.AutoRotate, state.Speed))
17+
}
18+
19+
func logStateReceive(state ControlState) {
20+
log(fmt.Sprintf("[State Receive] AutoRotate: %t, Speed: %f", state.AutoRotate, state.Speed))
21+
}

0 commit comments

Comments
 (0)