mcpField
M
menu-debug

menu-debug

github.com/openharmonyinsight开发3575 次安装11 周前更新
代码仓库

关于 menu-debug

menu-debug 是用于 OpenHarmony ACE Engine Menu 组件问题排查的调试技能,面向分析菜单布局、子窗口和交互故障的开发者。它按症状分类并提供代码定位、日志检查与日志补丁指导。

主要功能

  1. 01按症状分类菜单故障
  2. 02定位关键代码位置
  3. 03指导筛选现有日志
  4. 04生成基于代码分析的日志补丁

适用场景

  1. 01排查菜单尺寸或布局错误
  2. 02分析子窗口重建与崩溃
  3. 03诊断点击无响应或自动关闭

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill menu-debug

安装后在 Claude Code 中输入/menu-debug确认已加载。

附带文件quick_reference.mdREADME.md

详细介绍

Menu 组件调试技能

针对 OpenHarmony ACE Engine 中 Menu 组件问题的系统化调试和诊断。本技能提供结构化的故障排查指南,并自动生成日志增强补丁。

概述

调试 Menu 组件需要分析多个层面:

  • 子窗口生命周期 — 窗口的创建、重建和销毁
  • Menu 布局算法 — 宽度计算、定位和约束处理
  • Menu 模式 — 状态管理、Menu 包装器和 Menu 项
  • 管线上下文 — 窗口矩形信息、主题设置和显示配置
  • 事件处理 — 点击检测、状态转换和手势处理

关键要求:

  • ⚠️ 所有日志补丁都必须基于实际代码分析 — 不得臆测
  • ⚠️ 日志补丁必须遵循 OpenHarmony 日志规范(TAG_LOGI/W/E 宏)
  • ⚠️ 始终提供上下文 — 在日志语句中包含相关变量值
  • ⚠️ 使用现有日志标签 — ACE_MENU、ACE_SUB_WINDOW、ACE_OVERLAY

问题类别

1. Menu 宽度问题

症状:

  • Menu 宽度显示为 0
  • Menu 显示得过窄或过宽
  • Menu 宽度计算错误

常见原因:

  • displayWindowRectInfo.Width() 返回 0(异步初始化尚未完成)
  • PipelineContext 来源问题(子窗口与主窗口)
  • Menu 参数配置错误
  • 主题设置问题
2. 子窗口重建问题

症状:

  • 频繁出现“recreate subwindow”日志
  • 快速打开时 Menu 无法显示
  • 窗口状态转换(ATTACHING/DETACHING)
  • Menu 显示空白或延迟

常见原因:

  • 快速打开 Menu(与 DETACHING 状态冲突)
  • Display ID 发生变化
  • Menu 包装器状态不匹配
3. Menu 布局问题

症状:

  • Menu 位置不正确
  • Menu 与目标重叠
  • Menu 被裁剪或截断
  • Menu 显示在屏幕的错误一侧

常见原因:

  • 窗口矩形计算错误
  • 偏移量计算问题
  • 设备类型问题(折叠屏手机)
  • 未考虑安全区域
4. Menu 崩溃/不稳定

症状:

  • 打开 Menu 时发生崩溃
  • Menu 意外消失
  • Menu 交互失败

常见原因:

  • 空指针解引用
  • Menu 模式生命周期问题
  • 状态管理错误
5. 点击响应问题

症状:

  • 点击 Menu 触发器无响应
  • 点击时 Menu 无法打开
  • Menu 交互响应延迟

常见原因:

  • 事件中心未正确初始化
  • 未注册手势事件
  • Menu 状态阻止了点击处理
6. Menu 自动关闭问题

症状:

  • Menu 打开后立即关闭
  • 点击时 Menu 消失
  • 未经用户交互,Menu 就关闭

常见原因:

  • Menu 包装器中的状态机问题
  • 触摸事件处理冲突
  • HideMenu 调用不正确
7. Menu 定位问题

症状:

  • Menu 定位在屏幕左上角
  • Menu 出现在错误的屏幕位置
  • Menu 放置位置计算错误

常见原因:

  • 偏移量计算问题
  • 锚点配置错误
  • MenuWindowRect 计算不正确
8. 安全区域/导航栏问题

症状:

  • Menu 与导航栏重叠
  • Menu 覆盖状态栏
  • Menu 未避开系统界面

常见原因:

  • 未应用安全区域内边距
  • 窗口矩形未考虑系统界面
  • 忽略了显示屏挖孔设置
9. Menu 尺寸问题

症状:

  • Menu 宽度为 0
  • Menu 高度为 0
  • Menu 尺寸计算结果为 0

常见原因:

  • 异步初始化时序问题
  • PipelineContext 尚未就绪
  • DisplayWindowRectInfo 未正确初始化

调试工作流

Step 1: Identify Problem Category

Based on symptoms, identify which problem category:

Width/Dimension Issues → Look for:

Menu width is 0
menuMaxWidth = 0
displayWindowRectInfo.Width() = 0

Subwindow Issues → Look for:

recreate subwindow
DETACHING state
MenuWindowRect

Layout Issues → Look for:

MenuOffset incorrect
position calculation error
menuWindowRect

Crash Issues → Look for:

Segmentation fault
Null pointer
CHECK_NULL_*

Click/Auto-Close Issues → Look for:

HideMenu called
state transition
gesture event not received

Positioning Issues → Look for:

anchorPoint calculation
MenuWindowRect values
offset errors
Step 2: Locate Key Code Locations

For Width/Dimension Issues:

  • menu_layout_algorithm.cpp:941 - UpdateChildConstraintByDevice
  • menu_layout_algorithm.cpp:3618 - GetMenuWindowRectInfo
  • menu_layout_algorithm.cpp:931 - Pipeline context source
  • menu_pattern.cpp - Menu wrapper initialization

For Subwindow Issues:

  • subwindow_manager.cpp:1954 - GetOrCreateMenuSubWindow
  • subwindow_manager.cpp:1965 - Recreate log
  • menu_wrapper_pattern.cpp - Menu wrapper lifecycle

For Layout Issues:

  • menu_layout_algorithm.cpp:3611-3659 - GetMenuWindowRectInfo
  • menu_pattern.cpp - Menu positioning
  • multi_menu_layout_algorithm.cpp - Multi-menu layout

For Click/Auto-Close Issues:

  • menu_wrapper_pattern.cpp - OnDetach/OnAttach
  • menu_pattern.cpp - Menu state management
  • menu_view.cpp - Event handling

For Positioning Issues:

  • menu_layout_algorithm.cpp - GetMenuWindowRectInfo
  • menu_pattern.cpp - Offset calculation
  • subwindow_manager.cpp - Window rect calculation
Step 3: Collect Existing Logs

Key log tags to filter:

# Menu-related logs
cat xxx.log | grep "ACE_MENU"
cat xxx.log | grep "ACE_SUB_WINDOW"
cat xxx.log | grep "ACE_OVERLAY"

# Specific issues
cat xxx.log | grep "recreate subwindow"
cat xxx.log | grep "DisplayWindowRectInfo"
cat xxx.log | grep "MenuWindowRect"
cat xxx.log | grep "HideMenu"
cat xxx.log | grep "OnClick"

Critical log patterns:

  • recreate subwindow → Subwindow recreation occurred
  • DisplayWindowRectInfo width is 0 → Width initialization problem
  • DETACHING → Window state transition
  • MenuWindowRect → Window rect calculation
  • HideMenu → Menu hide operation

New Problem Analysis (v0.2.0)

Problem 1: 点击无响应/点击弹不出来菜单 (Click No Response)

Symptoms:

  • 点击菜单触发器没有反应
  • 点击后菜单不弹出
  • 没有任何错误日志
  • 点击事件似乎被忽略

Possible Causes:

  1. 事件中心未正确初始化

    • GestureEventHub 没有获取或创建
    • Pan event 没有注册到菜单组件
  2. 菜单状态不正确

    • MenuWrapper 处于 DETACHING 状态
    • MenuPattern 的状态机阻止了新事件
  3. 点击区域被遮挡

    • 其他组件覆盖了菜单的点击区域
    • Window z-order 问题
  4. 事件被消费

    • 其他组件拦截了点击事件
    • Touch event 没有传递到菜单

Debug Steps:

  1. 检查事件注册

    # 查找菜单事件相关日志
    cat xxx.log | grep "OnClick"
    cat xxx.log | grep "GestureEventHub"
    
  2. 检查菜单状态

    # 查找菜单状态
    cat xxx.log | grep "MenuWrapper"
    cat xxx.log | grep "MenuState"
    
  3. 检查 window 状态

    # 查找子窗口状态
    cat xxx.log | grep "ACE_SUB_WINDOW"
    cat xxx.log | grep "MenuWindowRect"
    

Code Locations:

  • menu_wrapper_pattern.cpp:OnDetach() - 状态转换
  • menu_pattern.cpp:OnClick - 点击处理
  • menu_view.cpp:Create() - 菜单创建流程

Solutions:

  1. 确保事件正确注册

    • 检查 GestureEventHub 初始化
    • 验证 Pan event 注册
    • 确认 event hub 传递正确
  2. 检查菜单状态机

    • 验证 OnModifyDone 时机
    • 确保 Menu 不在阻止状态
    • 检查 isShowing_ 状态
  3. 验证点击区域

    • 检查是否有组件遮挡
    • 验证 hitTestStack 配置
    • 确认触摸事件传递
  4. 添加调试日志

    // 在点击处理中添加日志
    TAG_LOGI(AceLogTag::ACE_MENU, "OnClick called: menuId=%{public}d", menuId);
    

Problem 2: 点击菜单立马就关闭了 (Menu Closes Immediately)

Symptoms:

  • 菜单打开后立即关闭
  • 点击菜单后菜单消失
  • 菜单闪现后消失
  • 看到 "HideMenu" 日志紧接着 "ShowMenu"

Possible Causes:

  1. 状态机错误

    • MenuWrapper 状态在 ATTACHING 和 DETACHED 间快速切换
    • OnDetach 被意外调用
    • 状态转换逻辑有缺陷
  2. 触摸事件冲突

    • 点击事件触发两次
    • Hide 和 Show 事件冲突
    • Touch down 和 touch up 事件处理错误
  3. Window 焦点问题

    • Window 失去焦点导致菜单关闭
    • Focus change event 触发隐藏
  4. 超时配置错误

    • Menu 超时时间设置为 0
    • Duration 太短导致立即关闭

Debug Steps:

  1. 检查状态转换日志

    # 查找快速的状态变化
    cat xxx.log | grep -E "ATTACHING|DETACHING" | head -20
    
  2. 检查 HideMenu 调用

    # 查找谁调用了 HideMenu
    cat xxx.log | grep "HideMenu" | grep -B 5 "ShowMenu"
    
  3. 检查触摸事件

    # 查找触摸事件
    cat xxx.log | grep "Touch"
    cat xxx.log | grep "Click"
    
  4. 检查窗口生命周期

    # 查找子窗口创建和销毁
    cat xxx.log | grep "GetOrCreateMenuSubWindow"
    cat xxx.log | grep "RemoveMenuSubWindow"
    

Code Locations:

  • menu_wrapper_pattern.cpp:OnDetach() - 状态管理
  • menu_wrapper_pattern.cpp:HideMenu() - 隐藏逻辑
  • menu_pattern.cpp - 状态机实现

Solutions:

  1. 修复状态转换逻辑

    • 添加状态转换日志
    • 添加转换条件检查
    • 防止非法状态转换
  2. 优化事件处理

    • 添加事件去重逻辑
    • 防止 Show/Hide 冲突
    • 添加事件处理延迟
  3. 检查焦点管理

    • 验证窗口焦点设置
    • 确认 focus 事件处理
    • 添加焦点状态日志
  4. 增加状态保护

    // 添加状态检查
    if (menuWrapperPattern->GetState() != MenuWrapperState::DETACHING) {
        TAG_LOGW(AceLogTag::ACE_MENU,
            "Invalid HideMenu call, current state=%{public}d",
            static_cast<int>(state));
        return;
    }
    

Problem 3: 弹出菜单位置在屏幕左上角 (Menu Positioned at Top-Left)

Symptoms:

  • 菜单位置在屏幕左上角 (0,0)
  • 菜单位置明显错误
  • 菜单没有跟随触发器
  • offset 计算错误

Possible Causes:

  1. Offset 计算错误

    • targetOffset 计算为 0
    • PositionOffset 未正确设置
    • 初始位置使用默认值
  2. 锚点配置错误

    • anchorPoint 未设置
    • anchorPosition 使用默认值
    • 菜单锚到错误位置
  3. MenuWindowRect 计算错误

    • GetMenuWindowRectInfo 返回错误值
    • displayWindowRect 信息错误
    • 子窗口尺寸计算失败
  4. Placement 配置未生效

    • UpdateMenuPlacement 没有被调用
    • placement 属性被忽略
    • AlignRule 配置错误

Debug Steps:

  1. 检查位置相关日志

    # 查找菜单位置计算
    cat xxx.log | grep "MenuOffset"
    cat xxx.log | grep "MenuPosition"
    cat xxx.log | grep "targetOffset"
    
  2. 检查窗口 Rect 信息

    # 查找窗口矩形
    cat xxx.log | grep "MenuWindowRect"
    cat xxx.log | grep "DisplayWindowRectInfo"
    
  3. 检查 placement 配置

    # 查找 placement 配置
    cat xxx.log | grep "placement"
    cat xxx.log | grep "anchor"
    

Code Locations:

  • menu_layout_algorithm.cpp:3611-3659 - GetMenuWindowRectInfo
  • menu_layout_algorithm.cpp - Offset 计算
  • menu_pattern.cpp - PositionOffset 更新
  • menu_view.cpp:1627 - UpdateMenuPlacement

Solutions:

  1. 验证 Offset 计算

    • 检查 targetOffset 是否正确
    • 验证 positionOffset 来源
    • 添加 offset 计算日志
  2. 检查锚点配置

    • 验证 anchorPoint 设置
    • 检查 anchorPosition 属性
    • 确认锚点计算逻辑
  3. 验证 Placement

    • 确保 UpdateMenuPlacement 被调用
    • 检查 AlignRule 配置
    • 验证 placement 类型
  4. 添加位置调试日志

    // 添加位置日志
    TAG_LOGI(AceLogTag::ACE_MENU,
        "Menu position: offset=(%{public}f,%{public}f), target=(%{public}f,%{public}f)",
        offsetX, offsetY, targetOffsetX, targetOffsetY);
    

Problem 4: 菜单弹出方向不对 (Menu Direction Incorrect)

Symptoms:

  • 菜单方向错误(应上弹却下弹)
  • 菜单与触发器方向不匹配
  • 子菜单展开方向错误
  • 菜单在错误侧弹出

Possible Causes:

  1. Direction 参数错误

    • fontSize 或 direction 参数配置错误
    • menuDirection 枚举值不正确
    • 箭头绘制方向错误
  2. Placement 计算错误

    • placement 类型判断错误
    • Top/Bottom/Left/Right 混淆
    • AlignRule 应用不正确
  3. Target 位置计算错误

    • 触发器位置获取错误
    • TargetOffset 使用错误值
    • 相对位置计算符号错误
  4. 布局算法方向错误

    • Column/Row 方向设置错误
    • crossAxis 配置错误
    • mainAxisSize 设置错误

Debug Steps:

  1. 检查方向相关配置

    # 查找方向配置
    cat xxx.log | grep -E "direction|font|arrow"
    
  2. 检查 placement 配置

    cat xxx.log | grep "placement"
    cat xxx.log | grep "AlignDirection"
    
  3. 检查布局方向

    cat xxx.log | grep "mainAxisSize"
    cat xxx.log | grep "crossAxis"
    

Code Locations:

  • menu_pattern.cpp - Direction 配置
  • menu_layout_algorithm.cpp - Placement 计算
  • menu_item/ - 菜单项布局

Solutions:

  1. 验证 Direction 参数

    • 检查 fontSize API 调用
    • 验证方向枚举值
    • 检查箭头绘制逻辑
  2. 修正 Placement 计算

    • 确保 placement 类型正确
    • 检查 Top/Bottom 判断逻辑
    • 验证对齐规则
  3. 检查目标位置

    • 验证 trigger 组件位置
    • 检查 targetOffset 计算
    • 确认相对位置方向
  4. 添加方向调试日志

    TAG_LOGI(AceLogTag::ACE_MENU,
        "Menu direction: placement=%{public}d, direction=%{public}d",
        placement, direction);
    

Problem 5: 菜单没有避让挖坑/导航条 (Menu Overlaps System UI)

Symptoms:

  • 菜单被导航栏遮挡
  • 菜单覆盖状态栏
  • 菜单没有考虑系统 UI 安全区域
  • 菜单部分在屏幕外

Possible Causes:

  1. SafeArea 未应用

    • GetSafeArea() 没有被调用
    • SafeArea insets 没有传递到布局
    • system_safe_area 属性未设置
  2. Window Rect 计算错误

    • displayWindowRect 没有考虑 safe area
    • Window 位置和尺寸计算错误
    • Cutout state 未应用
  3. Z-Order 问题

    • 菜单 window 层级错误
    • Window type 不是 PANEL 类型
    • Z-order 配置不正确
  4. Maximize 设置错误

    • LayoutFullScreen 使用错误
    • Window mode 设置为 FULLSCREEN 而非 FLOATING
    • 布局约束配置错误

Debug Steps:

  1. 检查 SafeArea 相关日志

    cat xxx.log | grep -i "safe|safeArea"
    
  2. 检查 Window Mode

    cat xxx.log | grep "LayoutFullScreen"
    cat xxx.log | grep "WindowMode"
    
  3. 检查 Window Rect

    cat xxx.log | grep "DisplayWindowRectInfo"
    

Code Locations:

  • subwindow_manager.cpp - Window 创建
  • menu_layout_algorithm.cpp - SafeArea 应用
  • Menu wrapper - Window 模式设置

Solutions:

  1. 应用 SafeArea 约束

    • 确保 GetSafeArea() 被调用
    • 将 safe area 传递给布局算法
    • 设置 system_safe_area 属性
  2. 调整 Window Mode

    • 使用 FLOATING 或 PANEL 类型
    • 避免 FULLSCREEN 模式
    • 设置合适的窗口属性
  3. 修正 Window Rect 计算

    • 在窗口 rect 中减去 safe area
    • 确保菜单在可见区域内
    • 验证 cutout 处理
  4. 验证 Z-Order

    • 检查 window type 配置
    • 确保菜单在正确层级
    • 验证与系统 UI 的关系

问题 6:菜单弹出宽度为 0/高度为 0(菜单宽度/高度为 0)

症状:

  • 菜单宽度计算为 0
  • 菜单高度计算为 0
  • Menu 显示异常狭窄或不显示
  • displayWindowRectInfo 返回 0 值

可能原因:

  1. 异步初始化未完成

    • 在 pipeline ready 前调用 GetDisplayWindowRectInfo
    • displayWindowRect 尚未初始化
    • 获取 display 信息的异步时机错误
  2. Pipeline Context 来源错误

    • 使用了 subwindow 的 context,而非 main window
    • Context 类型判断错误
    • PipelineContext 初始化时机有误
  3. MenuParam 配置错误

    • fontSize 参数未解析
    • MenuParam 传递错误
    • 属性值未正确设置
  4. 计算公式错误

    • menuMaxWidthRatio 计算为 0
    • displayWidth 乘以了错误系数
    • theme 返回值使用错误

调试步骤:

  1. 检查 displayWidth 相关日志

    # 查找宽度计算
    cat xxx.log | grep "displayWidth"
    cat xxx.log | grep "displayWindowRect.Width"
    cat xxx.log | grep "menuMaxWidthRatio"
    
  2. 检查 MenuParam

    cat xxx.log | grep "MenuParam"
    cat xxx.log | grep "fontSize"
    
  3. 检查 Pipeline Context

    cat xxx.log | grep "PipelineContext"
    cat xxx.log | grep "GetMainPipelineContext"
    

代码位置:

  • menu_layout_algorithm.cpp:920-966 - UpdateChildConstraintByDevice
  • menu_layout_algorithm.cpp:3618 - GetMenuWindowRectInfo
  • menu_pattern.cpp - MenuParam 处理
  • Theme 相关 - menuMaxWidthRatio 配置

解决方案:

  1. 添加初始化检查

    // 在 GetMenuWindowRectInfo 中添加检查
    auto displayWidth = displayWindowRectInfo.Width();
    if (displayWidth <= 0.0f) {
        TAG_LOGE(AceLogTag::ACE_MENU,
            "Invalid displayWidth=%{public}f, waiting for async init",
            displayWidth);
        return menuWindowRect;
    }
    
  2. 验证 Context 来源

    • 检查是否应该使用 main window context
    • 验证 PipelineContext 类型
    • 添加 context 来源日志
  3. 延迟宽度计算

    • 在异步初始化完成前使用默认宽度
    • 添加 ready 状态检查
    • 避免使用未初始化的值
  4. 添加异步初始化日志

    TAG_LOGI(AceLogTag::ACE_MENU,
        "Async display init: displayWidth=%{public}f, ready=%{public}d",
        displayWidth, IsDisplayReady());
    

日志增强参考

关键日志模式

1. 状态转换日志

TAG_LOGI(AceLogTag::ACE_SUB_WINDOW,
    "Subwindow state transition: %{public}d -> %{public}d",
    static_cast<int>(oldState), static_cast<int>(newState));

2. 值上下文日志

TAG_LOGI(AceLogTag::ACE_MENU,
    "Calculation: displayWidth=%{public}f, menuMaxWidthRatio=%{public}f, result=%{public}f",
    displayWidth, menuMaxWidthRatio, menuMaxWidth);

3. 代码路径日志

TAG_LOGI(AceLogTag::ACE_MENU,
    "GetMenuWindowRectInfo: host=%{public}p, menuId=%{public}d, targetTag=%{public}d, targetNodeId=%{public}d",
    host.Get(), menuPattern->GetMenuId(), targetTag_, targetNodeId_);

4. 错误上下文日志

if (displayWidth <= 0.0f) {
    TAG_LOGE(AceLogTag::ACE_MENU,
        "Invalid displayWidth=%{public}f, expected>%{public}f",
        displayWidth, expectedWidth);
    return;
}
需要记录的关键变量

宽度/高度问题:

  • displayWindowRectInfo.Width() / Height()
  • menuMaxWidth / menuMaxHeight
  • menuMaxWidthRatio / menuMaxHeightRatio
  • theme->GetMenuMaxWidthRatio()
  • pipeline->GetDisplayWindowRectInfo()

子窗口问题:

  • subwindow->GetDetachState()
  • subwindow->GetShown()
  • subwindow->GetRect().GetSize()
  • instanceId / searchKey.ToString()

布局问题:

  • menuWindowRect(所有字段)
  • targetOffset_ / targetSize_
  • GetMenuWindowRectInfo() 返回值
  • placement / anchorPosition

快速参考:代码位置

问题类型文件行号函数关键变量
点击问题menu_wrapper_pattern.cpp-OnDetach / OnAttachstate_
自动关闭menu_pattern.cpp-状态机isShowing_
位置(左上角)menu_layout_algorithm.cpp3611-3659GetMenuWindowRectInfomenuWindowRect
方向menu_pattern.cpp-direction_ / placement-
安全区域subwindow_manager.cpp-窗口创建参数-
宽度=0/高度=0menu_layout_algorithm.cpp920-966UpdateChildConstraintByDevicedisplayWidth

日志筛选命令

提取所有 Menu 相关日志:

# Comprehensive Menu logs
grep -E "ACE_MENU|ACE_SUB_WINDOW|ACE_OVERLAY" xxx.log > menu_debug.log

# Width-specific logs
grep -E "DisplayWindowRectInfo|menuMaxWidth|displayWidth" xxx.log

# Subwindow recreation logs
grep -E "recreate subwindow|DETACHING|MenuWindowState" xxx.log

# Positioning logs
grep -E "MenuOffset|MenuPosition|targetOffset|placement" xxx.log

# Click/Event logs
grep -E "OnClick|TouchEvent|GestureEvent" xxx.log

按特定实例筛选:

# For specific container ID
grep "instanceId: 123" xxx.log

# For specific menu node
grep "menuId: 456" xxx.log

最佳实践

日志增强原则

应该:

  • ✅ 添加上下文——记录相关变量值
  • ✅ 记录状态转换——旧值 → 新值
  • ✅ 使用恰当的日志级别——正常情况使用 INFO,异常情况使用 WARN,失败情况使用 ERROR
  • ✅ 包含标识符——节点 ID、实例 ID
  • ✅ 记录计算过程——输入值和结果
  • ✅ 尽量少改动——只添加日志,不修改逻辑
  • ✅ 使用现有宏——带正确标签的 TAG_LOGI/W/E
  • ✅ 测试编译——应用前验证语法
  • ✅ 记录变更——注明每条日志的内容和原因

不应该:

  • ❌ 不带上下文地记录日志——只写“进入函数”
  • ❌ 记录过多——在循环中输出过多日志
  • ❌ 记录敏感数据——用户信息、令牌
  • ❌ 猜测——只记录实际值
  • ❌ 修改逻辑——只添加日志语句
补丁生成指南
  1. 尽量少改动——只添加日志,不修改逻辑
  2. 保留格式——遵循现有代码风格
  3. 使用现有宏——带正确标签的 TAG_LOGI/W/E
  4. 测试编译——应用前验证语法
  5. 记录变更——注明每条日志的内容和原因
  6. 记录上下文——在日志中包含周边代码状态
Analysis Workflow
  1. Gather baseline - Collect logs without issue if possible
  2. Apply patch - Add targeted logging
  3. Reproduce issue - Trigger problem with enhanced logging
  4. Extract relevant logs - Filter specific log tags
  5. Trace execution flow - Follow log sequence through code
  6. Identify root cause - Find where unexpected behavior occurs
  7. Implement fix - Address identified issue
  8. Verify resolution - Confirm fix works, remove debug logs if needed

Integration with Other Skills

This skill complements:

  • compile-analysis - For performance issues in Menu code
  • build-error-analyzer - If Menu changes cause build failures
  • xts-component-test - For writing Menu test cases

Version History

  • 0.2.0 (2026-02-12): 新增6个常见问题分析

    • 💫 添加点击无响应问题分析
    • 💫 添加菜单自动关闭问题分析
    • 💫 添加菜单位置左上角问题分析
    • 💫 添加菜单方向不对问题分析
    • 💫 添加菜单避让导航条问题分析
    • 💫 添加宽度/高度为0问题分析
    • 📝 为每个问题提供详细调试步骤和解决方案
    • 🎯 扩展触发关键词覆盖常见用户问题
  • 0.1.0 (2026-02-12): 初始版本

    • ✨ 完整的 Menu 组件调试 skill
    • 📝 覆盖宽度、子窗口、布局、崩溃等4大类问题
    • 🔧 提供系统化调试工作流程
    • 📊 包含关键代码位置和变量参考
    • 🎯 自动化日志增强补丁生成

评论

支持 Markdown