Skip to content

Dock.load_state() causes DrawList corruption, rendering blank main page #45

Description

@ZhangHanDong

Summary

Restoring the Dock layout from persisted state via Dock.load_state() corrupts Makepad's internal DrawList references, causing the entire main content area (rooms list + room tabs) to render as a blank grey page after app restart.

Symptoms

  • Left navigation bar renders correctly
  • Main content area (Dock with RoomsSideBar + room tabs) is completely blank/grey
  • Console floods with Drawlist id generation wrong errors:
    [E] draw_list.rs:324: Drawlist id generation wrong index: 21 current gen:1 in pointer:0
    

Root Cause

Dock.load_state() (Makepad widgets/src/dock.rs:1310) destroys DrawList2d objects by calling self.tab_bars.clear() during event handling. The Makepad rendering pipeline still holds cached DrawListId references from the previous frame, causing generation mismatches when the freed pool entries are accessed.

Key sequence:

  1. First draw creates tab_bars with DrawList2d at pool index N, generation 0
  2. RestoreAppStateFromPersistentState triggers load_state() during event handling
  3. tab_bars.clear() drops DrawList2d → pool[N].generation increments to 1
  4. Next frame accesses stale DrawListId(N, gen=0) → generation mismatch → blank rendering

Reproduction

  1. Run the app, log in, open some room tabs
  2. Close the app (state persists to latest_app_state.json)
  3. Restart → blank main page

Verification: Deleting latest_app_state.json → UI renders correctly with 0 DrawList errors.

Fix Applied

Replaced dock.load_state(dock_items) in load_dock_state_from() with programmatic tab recreation via close_all_tabs() + focus_or_create_tab(), which uses the Dock's normal widget API and avoids direct DrawList destruction.

See issues/001-dock-load-state-drawlist-corruption.md for full details.

Remaining Issues

  • Splitter position not restored — custom sidebar width resets to 300px on restart
  • Multi-pane layout not restored — drag-created split-view arrangements lost on restart
  • Upstream Makepad bugDock.load_state() should properly handle DrawList lifecycle when called during event handling (needs fix in kevinaboos/makepad stack_nav_improvements branch)
  • Unrelated: SETTINGS_BUTTON_HEIGHT undefined in account_settings.rs:63,86

Environment

  • Makepad: kevinaboos/makepad@stack_nav_improvements (461b0513)
  • Platform: macOS (Darwin 24.5.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions