Menu Component Debugging Skill
Systematic debugging and problem diagnosis for Menu component issues in OpenHarmony ACE Engine. This skill provides structured troubleshooting guidance for Menu-related problems with automatic log enhancement patch generation.
Overview
Menu component debugging requires analyzing multiple layers:
- Subwindow lifecycle - Window creation, recreation, and destruction
- Menu layout algorithm - Width calculation, positioning, and constraint handling
- Menu pattern - State management, menu wrapper, and menu items
- Pipeline context - Window rect info, theme settings, and display configuration
- Event handling - Click detection, state transitions, and gesture processing
Critical Requirements:
- ⚠️ All log patches MUST be based on actual code analysis - no speculation
- ⚠️ Log patches MUST follow OpenHarmony logging standards (TAG_LOGI/W/E macros)
- ⚠️ Always provide context - include relevant variable values in log statements
- ⚠️ Use existing log tags - ACE_MENU, ACE_SUB_WINDOW, ACE_OVERLAY
Problem Categories
1. Menu Width Issues
Symptoms:
- Menu width displays as 0
- Menu appears too narrow or wide
- Menu width calculation errors
Common Causes:
displayWindowRectInfo.Width() returns 0 (async initialization not complete)
- PipelineContext source issues (subwindow vs main window)
- Menu parameter configuration Errors
- Theme settings problems
2. Subwindow Recreation Issues
Symptoms:
- Frequent "recreate subwindow" logs
- Menu fails to show on rapid open
- Window state transitions (ATTACHING/DETACHING)
- Menu displays blank or delayed
Common Causes:
- Quick Menu opening (DETACHING state conflict)
- Display ID changes
- Menu wrapper state mismatches
3. Menu Layout Issues
Symptoms:
- Menu positioned incorrectly
- Menu overlaps with target
- Menu clipped or truncated
- Menu displays on wrong screen side
Common Causes:
- Window rect calculation errors
- Offset calculation problems
- Device type issues (foldable phones)
- Safe area not considered
4. Menu Crash/Instability
Symptoms:
- Menu crashes when opening
- Menu disappears unexpectedly
- Menu interaction failures
Common Causes:
- Null pointer dereferences
- Menu pattern lifecycle issues
- State management errors
5. Click Response Issues
Symptoms:
- Click on menu trigger has no response
- Menu fails to open when clicked
- Delayed response to menu interaction
Common Causes:
- Event hub not properly initialized
- Gesture event not registered
- Menu state prevents click handling
6. Menu Auto-Close Issues
Symptoms:
- Menu closes immediately after opening
- Menu disappears when clicked
- Menu closes without user interaction
Common Causes:
- State machine issues in menu wrapper
- Touch event handling conflicts
- HideMenu called incorrectly
7. Menu Positioning Issues
Symptoms:
- Menu positioned at screen top-left corner
- Menu appears at wrong screen position
- Menu placement calculation errors
Common Causes:
- Offset calculation problems
- Anchor point configuration errors
- MenuWindowRect calculation incorrect
8. Safe Area/Navigation Bar Issues
Symptoms:
- Menu overlaps with navigation bar
- Menu covers status bar
- Menu doesn't avoid system UI
Common Causes:
- Safe area insets not applied
- Window rect doesn't account for system UI
- Display cutout settings ignored
9. Menu Dimension Issues
Symptoms:
- Menu width is 0
- Menu height is 0
- Menu size calculations return 0
Common Causes:
- Async initialization timing
- Pipeline context not ready
- DisplayWindowRectInfo not properly initialized
Debugging Workflow
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:
事件中心未正确初始化
- GestureEventHub 没有获取或创建
- Pan event 没有注册到菜单组件
菜单状态不正确
- MenuWrapper 处于 DETACHING 状态
- MenuPattern 的状态机阻止了新事件
点击区域被遮挡
- 其他组件覆盖了菜单的点击区域
- Window z-order 问题
事件被消费
- 其他组件拦截了点击事件
- Touch event 没有传递到菜单
Debug Steps:
检查事件注册
# 查找菜单事件相关日志
cat xxx.log | grep "OnClick"
cat xxx.log | grep "GestureEventHub"
检查菜单状态
# 查找菜单状态
cat xxx.log | grep "MenuWrapper"
cat xxx.log | grep "MenuState"
检查 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:
确保事件正确注册
- 检查 GestureEventHub 初始化
- 验证 Pan event 注册
- 确认 event hub 传递正确
检查菜单状态机
- 验证 OnModifyDone 时机
- 确保 Menu 不在阻止状态
- 检查 isShowing_ 状态
验证点击区域
- 检查是否有组件遮挡
- 验证 hitTestStack 配置
- 确认触摸事件传递
添加调试日志
// 在点击处理中添加日志
TAG_LOGI(AceLogTag::ACE_MENU, "OnClick called: menuId=%{public}d", menuId);
Problem 2: 点击菜单立马就关闭了 (Menu Closes Immediately)
Symptoms:
- 菜单打开后立即关闭
- 点击菜单后菜单消失
- 菜单闪现后消失
- 看到 "HideMenu" 日志紧接着 "ShowMenu"
Possible Causes:
状态机错误
- MenuWrapper 状态在 ATTACHING 和 DETACHED 间快速切换
- OnDetach 被意外调用
- 状态转换逻辑有缺陷
触摸事件冲突
- 点击事件触发两次
- Hide 和 Show 事件冲突
- Touch down 和 touch up 事件处理错误
Window 焦点问题
- Window 失去焦点导致菜单关闭
- Focus change event 触发隐藏
超时配置错误
- Menu 超时时间设置为 0
- Duration 太短导致立即关闭
Debug Steps:
检查状态转换日志
# 查找快速的状态变化
cat xxx.log | grep -E "ATTACHING|DETACHING" | head -20
检查 HideMenu 调用
# 查找谁调用了 HideMenu
cat xxx.log | grep "HideMenu" | grep -B 5 "ShowMenu"
检查触摸事件
# 查找触摸事件
cat xxx.log | grep "Touch"
cat xxx.log | grep "Click"
检查窗口生命周期
# 查找子窗口创建和销毁
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:
修复状态转换逻辑
- 添加状态转换日志
- 添加转换条件检查
- 防止非法状态转换
优化事件处理
- 添加事件去重逻辑
- 防止 Show/Hide 冲突
- 添加事件处理延迟
检查焦点管理
- 验证窗口焦点设置
- 确认 focus 事件处理
- 添加焦点状态日志
增加状态保护
// 添加状态检查
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:
Offset 计算错误
- targetOffset 计算为 0
- PositionOffset 未正确设置
- 初始位置使用默认值
锚点配置错误
- anchorPoint 未设置
- anchorPosition 使用默认值
- 菜单锚到错误位置
MenuWindowRect 计算错误
- GetMenuWindowRectInfo 返回错误值
- displayWindowRect 信息错误
- 子窗口尺寸计算失败
Placement 配置未生效
- UpdateMenuPlacement 没有被调用
- placement 属性被忽略
- AlignRule 配置错误
Debug Steps:
检查位置相关日志
# 查找菜单位置计算
cat xxx.log | grep "MenuOffset"
cat xxx.log | grep "MenuPosition"
cat xxx.log | grep "targetOffset"
检查窗口 Rect 信息
# 查找窗口矩形
cat xxx.log | grep "MenuWindowRect"
cat xxx.log | grep "DisplayWindowRectInfo"
检查 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:
验证 Offset 计算
- 检查 targetOffset 是否正确
- 验证 positionOffset 来源
- 添加 offset 计算日志
检查锚点配置
- 验证 anchorPoint 设置
- 检查 anchorPosition 属性
- 确认锚点计算逻辑
验证 Placement
- 确保 UpdateMenuPlacement 被调用
- 检查 AlignRule 配置
- 验证 placement 类型
添加位置调试日志
// 添加位置日志
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:
Direction 参数错误
- fontSize 或 direction 参数配置错误
- menuDirection 枚举值不正确
- 箭头绘制方向错误
Placement 计算错误
- placement 类型判断错误
- Top/Bottom/Left/Right 混淆
- AlignRule 应用不正确
Target 位置计算错误
- 触发器位置获取错误
- TargetOffset 使用错误值
- 相对位置计算符号错误
布局算法方向错误
- Column/Row 方向设置错误
- crossAxis 配置错误
- mainAxisSize 设置错误
Debug Steps:
检查方向相关配置
# 查找方向配置
cat xxx.log | grep -E "direction|font|arrow"
检查 placement 配置
cat xxx.log | grep "placement"
cat xxx.log | grep "AlignDirection"
检查布局方向
cat xxx.log | grep "mainAxisSize"
cat xxx.log | grep "crossAxis"
Code Locations:
menu_pattern.cpp - Direction 配置
menu_layout_algorithm.cpp - Placement 计算
menu_item/ - 菜单项布局
Solutions:
验证 Direction 参数
- 检查 fontSize API 调用
- 验证方向枚举值
- 检查箭头绘制逻辑
修正 Placement 计算
- 确保 placement 类型正确
- 检查 Top/Bottom 判断逻辑
- 验证对齐规则
检查目标位置
- 验证 trigger 组件位置
- 检查 targetOffset 计算
- 确认相对位置方向
添加方向调试日志
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:
SafeArea 未应用
- GetSafeArea() 没有被调用
- SafeArea insets 没有传递到布局
- system_safe_area 属性未设置
Window Rect 计算错误
- displayWindowRect 没有考虑 safe area
- Window 位置和尺寸计算错误
- Cutout state 未应用
Z-Order 问题
- 菜单 window 层级错误
- Window type 不是 PANEL 类型
- Z-order 配置不正确
Maximize 设置错误
- LayoutFullScreen 使用错误
- Window mode 设置为 FULLSCREEN 而非 FLOATING
- 布局约束配置错误
Debug Steps:
检查 SafeArea 相关日志
cat xxx.log | grep -i "safe|safeArea"
检查 Window Mode
cat xxx.log | grep "LayoutFullScreen"
cat xxx.log | grep "WindowMode"
检查 Window Rect
cat xxx.log | grep "DisplayWindowRectInfo"
Code Locations:
subwindow_manager.cpp - Window 创建
menu_layout_algorithm.cpp - SafeArea 应用
- Menu wrapper - Window 模式设置
Solutions:
应用 SafeArea 约束
- 确保 GetSafeArea() 被调用
- 将 safe area 传递给布局算法
- 设置 system_safe_area 属性
调整 Window Mode
- 使用 FLOATING 或 PANEL 类型
- 避免 FULLSCREEN 模式
- 设置合适的窗口属性
修正 Window Rect 计算
- 在窗口 rect 中减去 safe area
- 确保菜单在可见区域内
- 验证 cutout 处理
验证 Z-Order
- 检查 window type 配置
- 确保菜单在正确层级
- 验证与系统 UI 的关系
Problem 6: 菜单弹出宽度为0/高度为0 (Menu Width/Height is 0)
Symptoms:
- 菜单宽度计算为 0
- 菜单高度计算为 0
- Menu 显示异常窄或不显示
- displayWindowRectInfo 返回 0 值
Possible Causes:
异步初始化未完成
- GetDisplayWindowRectInfo 在 pipeline ready 前调用
- displayWindowRect 还未初始化
- 异步获取 display 信息时机错误
Pipeline Context 来源错误
- 使用了 subwindow 的 context 而非 main window
- Context 类型判断错误
- PipelineContext 初始化时机问题
MenuParam 配置错误
- fontSize 参数未解析
- MenuParam 传递错误
- 属性值未正确设置
计算公式错误
- menuMaxWidthRatio 计算为 0
- displayWidth 乘以错误系数
- theme 返回值使用错误
Debug Steps:
检查 displayWidth 相关日志
# 查找宽度计算
cat xxx.log | grep "displayWidth"
cat xxx.log | grep "displayWindowRect.Width"
cat xxx.log | grep "menuMaxWidthRatio"
检查 MenuParam
cat xxx.log | grep "MenuParam"
cat xxx.log | grep "fontSize"
检查 Pipeline Context
cat xxx.log | grep "PipelineContext"
cat xxx.log | grep "GetMainPipelineContext"
Code Locations:
menu_layout_algorithm.cpp:920-966 - UpdateChildConstraintByDevice
menu_layout_algorithm.cpp:3618 - GetMenuWindowRectInfo
menu_pattern.cpp - MenuParam 处理
- Theme 相关 - menuMaxWidthRatio 配置
Solutions:
添加初始化检查
// 在 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;
}
验证 Context 来源
- 检查是否应该使用 main window context
- 验证 PipelineContext 类型
- 添加 context 来源日志
延迟宽度计算
- 在异步初始化完成前使用默认宽度
- 添加 ready 状态检查
- 防止使用未初始化的值
添加异步初始化日志
TAG_LOGI(AceLogTag::ACE_MENU,
"Async display init: displayWidth=%{public}f, ready=%{public}d",
displayWidth, IsDisplayReady());
Log Enhancement Reference
Key Logging Patterns
1. State Transition Logging
TAG_LOGI(AceLogTag::ACE_SUB_WINDOW,
"Subwindow state transition: %{public}d -> %{public}d",
static_cast<int>(oldState), static_cast<int>(newState));
2. Value Context Logging
TAG_LOGI(AceLogTag::ACE_MENU,
"Calculation: displayWidth=%{public}f, menuMaxWidthRatio=%{public}f, result=%{public}f",
displayWidth, menuMaxWidthRatio, menuMaxWidth);
3. Code Path Logging
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. Error Context Logging
if (displayWidth <= 0.0f) {
TAG_LOGE(AceLogTag::ACE_MENU,
"Invalid displayWidth=%{public}f, expected>%{public}f",
displayWidth, expectedWidth);
return;
}
Critical Variables to Log
For Width/Height Issues:
displayWindowRectInfo.Width() / Height()
menuMaxWidth / menuMaxHeight
menuMaxWidthRatio / menuMaxHeightRatio
theme->GetMenuMaxWidthRatio()
pipeline->GetDisplayWindowRectInfo()
For Subwindow Issues:
subwindow->GetDetachState()
subwindow->GetShown()
subwindow->GetRect().GetSize()
instanceId / searchKey.ToString()
For Layout Issues:
menuWindowRect (all fields)
targetOffset_ / targetSize_
GetMenuWindowRectInfo() return value
placement / anchorPosition
Quick Reference Code Locations
| Problem Type |
File |
Line(s) |
Function |
Key Variables |
| Click issues |
menu_wrapper_pattern.cpp |
- |
OnDetach / OnAttach |
state_ |
| Auto-close |
menu_pattern.cpp |
- |
State machine |
isShowing_ |
| Position (top-left) |
menu_layout_algorithm.cpp |
3611-3659 |
GetMenuWindowRectInfo |
menuWindowRect |
| Direction |
menu_pattern.cpp |
- |
direction_ / placement |
- |
| Safe area |
subwindow_manager.cpp |
- |
Window creation params |
- |
| Width=0/Height=0 |
menu_layout_algorithm.cpp |
920-966 |
UpdateChildConstraintByDevice |
displayWidth |
Log Filtering Commands
Extract all Menu-related logs:
# 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
Filter by specific instance:
# For specific container ID
grep "instanceId: 123" xxx.log
# For specific menu node
grep "menuId: 456" xxx.log
Best Practices
Log Enhancement Principles
DO:
- ✅ Add context - log relevant variable values
- ✅ Log state transitions - old → new
- ✅ Use appropriate log level - INFO for normal, WARN for unexpected, ERROR for failures
- ✅ Include identifiers - node IDs, instance IDs
- ✅ Log calculations - input values and results
- ✅ Minimal changes - Only add logging, don't modify logic
- ✅ Use existing macros - TAG_LOGI/W/E with correct tags
- ✅ Test compilation - Verify syntax before applying
- ✅ Document changes - Note what and why for each log
DON'T:
- ❌ Log without context - just "entered function"
- ❌ Over-log - excessive logging in loops
- ❌ Log sensitive data - user information, tokens
- ❌ Speculate - log actual values only
- ❌ Modify logic - Only add logging statements
Patch Generation Guidelines
- Minimal Changes - Only add logging, don't modify logic
- Preserve Formatting - Follow existing code style
- Use Existing Macros - TAG_LOGI/W/E with correct tags
- Test Compilation - Verify syntax before applying
- Document Changes - Note what and why for each log
- Contextual Logging - Include surrounding code state in logs
Analysis Workflow
- Gather baseline - Collect logs without issue if possible
- Apply patch - Add targeted logging
- Reproduce issue - Trigger problem with enhanced logging
- Extract relevant logs - Filter specific log tags
- Trace execution flow - Follow log sequence through code
- Identify root cause - Find where unexpected behavior occurs
- Implement fix - Address identified issue
- 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
1---2name: menu-debug3description: This skill should be used when user asks to "Menu宽度为0", "Menu宽度问题", "Menu显示异常", "Menu子窗口问题", "Menu layout异常", "recreate subwindow", "快速打开Menu问题", "Menu闪退", "Menu位置错误", "子窗口recreate", "Menu崩溃", "Menu打印recreate", "点击无响应", "点击菜单关闭", "菜单位置左上角", "菜单方向不对", "菜单避让坑", "宽度高度为0", or mentions any Menu component issues like Menu width being 0, Menu display problems, Menu subwindow issues, Menu layout exceptions, positioning errors, crashes, click response issues, menu closing immediately, incorrect positioning, direction issues, safe area issues, or zero width/height problems. Provides systematic debugging guidance for Menu component issues including width problems, subwindow recreation, layout exceptions, positioning errors, crash analysis, click issues, menu positioning, and dimension problems with automatic log enhancement patch generation.4---56# Menu Component Debugging Skill78Systematic debugging and problem diagnosis for Menu component issues in OpenHarmony ACE Engine. This skill provides structured troubleshooting guidance for Menu-related problems with automatic log enhancement patch generation.910## Overview1112Menu component debugging requires analyzing multiple layers:13- **Subwindow lifecycle** - Window creation, recreation, and destruction14- **Menu layout algorithm** - Width calculation, positioning, and constraint handling15- **Menu pattern** - State management, menu wrapper, and menu items16- **Pipeline context** - Window rect info, theme settings, and display configuration17- **Event handling** - Click detection, state transitions, and gesture processing1819**Critical Requirements**:20- ⚠️ **All log patches MUST be based on actual code analysis** - no speculation21- ⚠️ **Log patches MUST follow OpenHarmony logging standards** (TAG_LOGI/W/E macros)22- ⚠️ **Always provide context** - include relevant variable values in log statements23- ⚠️ **Use existing log tags** - ACE_MENU, ACE_SUB_WINDOW, ACE_OVERLAY2425## Problem Categories2627### 1. Menu Width Issues28**Symptoms**:29- Menu width displays as 030- Menu appears too narrow or wide31- Menu width calculation errors3233**Common Causes**:34- `displayWindowRectInfo.Width()` returns 0 (async initialization not complete)35- PipelineContext source issues (subwindow vs main window)36- Menu parameter configuration Errors37- Theme settings problems3839### 2. Subwindow Recreation Issues40**Symptoms**:41- Frequent "recreate subwindow" logs42- Menu fails to show on rapid open43- Window state transitions (ATTACHING/DETACHING)44- Menu displays blank or delayed4546**Common Causes**:47- Quick Menu opening (DETACHING state conflict)48- Display ID changes49- Menu wrapper state mismatches5051### 3. Menu Layout Issues52**Symptoms**:53- Menu positioned incorrectly54- Menu overlaps with target55- Menu clipped or truncated56- Menu displays on wrong screen side5758**Common Causes**:59- Window rect calculation errors60- Offset calculation problems61- Device type issues (foldable phones)62- Safe area not considered6364### 4. Menu Crash/Instability65**Symptoms**:66- Menu crashes when opening67- Menu disappears unexpectedly68- Menu interaction failures6970**Common Causes**:71- Null pointer dereferences72- Menu pattern lifecycle issues73- State management errors7475### 5. Click Response Issues76**Symptoms**:77- Click on menu trigger has no response78- Menu fails to open when clicked79- Delayed response to menu interaction8081**Common Causes**:82- Event hub not properly initialized83- Gesture event not registered84- Menu state prevents click handling8586### 6. Menu Auto-Close Issues87**Symptoms**:88- Menu closes immediately after opening89- Menu disappears when clicked90- Menu closes without user interaction9192**Common Causes**:93- State machine issues in menu wrapper94- Touch event handling conflicts95- HideMenu called incorrectly9697### 7. Menu Positioning Issues98**Symptoms**:99- Menu positioned at screen top-left corner100- Menu appears at wrong screen position101- Menu placement calculation errors102103**Common Causes**:104- Offset calculation problems105- Anchor point configuration errors106- MenuWindowRect calculation incorrect107108### 8. Safe Area/Navigation Bar Issues109**Symptoms**:110- Menu overlaps with navigation bar111- Menu covers status bar112- Menu doesn't avoid system UI113114**Common Causes**:115- Safe area insets not applied116- Window rect doesn't account for system UI117- Display cutout settings ignored118119### 9. Menu Dimension Issues120**Symptoms**:121- Menu width is 0122- Menu height is 0123- Menu size calculations return 0124125**Common Causes**:126- Async initialization timing127- Pipeline context not ready128- DisplayWindowRectInfo not properly initialized129130## Debugging Workflow131132### Step 1: Identify Problem Category133134Based on symptoms, identify which problem category:135136**Width/Dimension Issues** → Look for:137```138Menu width is 0139menuMaxWidth = 0140displayWindowRectInfo.Width() = 0141```142143**Subwindow Issues** → Look for:144```145recreate subwindow146DETACHING state147MenuWindowRect148```149150**Layout Issues** → Look for:151```152MenuOffset incorrect153position calculation error154menuWindowRect155```156157**Crash Issues** → Look for:158```159Segmentation fault160Null pointer161CHECK_NULL_*162```163164**Click/Auto-Close Issues** → Look for:165```166HideMenu called167state transition168gesture event not received169```170171**Positioning Issues** → Look for:172```173anchorPoint calculation174MenuWindowRect values175offset errors176```177178### Step 2: Locate Key Code Locations179180**For Width/Dimension Issues**:181- `menu_layout_algorithm.cpp:941` - UpdateChildConstraintByDevice182- `menu_layout_algorithm.cpp:3618` - GetMenuWindowRectInfo183- `menu_layout_algorithm.cpp:931` - Pipeline context source184- `menu_pattern.cpp` - Menu wrapper initialization185186**For Subwindow Issues**:187- `subwindow_manager.cpp:1954` - GetOrCreateMenuSubWindow188- `subwindow_manager.cpp:1965` - Recreate log189- `menu_wrapper_pattern.cpp` - Menu wrapper lifecycle190191**For Layout Issues**:192- `menu_layout_algorithm.cpp:3611-3659` - GetMenuWindowRectInfo193- `menu_pattern.cpp` - Menu positioning194- `multi_menu_layout_algorithm.cpp` - Multi-menu layout195196**For Click/Auto-Close Issues**:197- `menu_wrapper_pattern.cpp` - OnDetach/OnAttach198- `menu_pattern.cpp` - Menu state management199- `menu_view.cpp` - Event handling200201**For Positioning Issues**:202- `menu_layout_algorithm.cpp` - GetMenuWindowRectInfo203- `menu_pattern.cpp` - Offset calculation204- `subwindow_manager.cpp` - Window rect calculation205206### Step 3: Collect Existing Logs207208**Key log tags to filter**:209```bash210# Menu-related logs211cat xxx.log | grep "ACE_MENU"212cat xxx.log | grep "ACE_SUB_WINDOW"213cat xxx.log | grep "ACE_OVERLAY"214215# Specific issues216cat xxx.log | grep "recreate subwindow"217cat xxx.log | grep "DisplayWindowRectInfo"218cat xxx.log | grep "MenuWindowRect"219cat xxx.log | grep "HideMenu"220cat xxx.log | grep "OnClick"221```222223**Critical log patterns**:224- `recreate subwindow` → Subwindow recreation occurred225- `DisplayWindowRectInfo width is 0` → Width initialization problem226- `DETACHING` → Window state transition227- `MenuWindowRect` → Window rect calculation228- `HideMenu` → Menu hide operation229230## New Problem Analysis (v0.2.0)231232### Problem 1: 点击无响应/点击弹不出来菜单 (Click No Response)233234**Symptoms**:235- 点击菜单触发器没有反应236- 点击后菜单不弹出237- 没有任何错误日志238- 点击事件似乎被忽略239240**Possible Causes**:2411. **事件中心未正确初始化**242 - GestureEventHub 没有获取或创建243 - Pan event 没有注册到菜单组件2442452. **菜单状态不正确**246 - MenuWrapper 处于 DETACHING 状态247 - MenuPattern 的状态机阻止了新事件2482493. **点击区域被遮挡**250 - 其他组件覆盖了菜单的点击区域251 - Window z-order 问题2522534. **事件被消费**254 - 其他组件拦截了点击事件255 - Touch event 没有传递到菜单256257**Debug Steps**:2582591. **检查事件注册**260 ```bash261 # 查找菜单事件相关日志262 cat xxx.log | grep "OnClick"263 cat xxx.log | grep "GestureEventHub"264 ```2652662. **检查菜单状态**267 ```bash268 # 查找菜单状态269 cat xxx.log | grep "MenuWrapper"270 cat xxx.log | grep "MenuState"271 ```2722733. **检查 window 状态**274 ```bash275 # 查找子窗口状态276 cat xxx.log | grep "ACE_SUB_WINDOW"277 cat xxx.log | grep "MenuWindowRect"278 ```279280**Code Locations**:281- `menu_wrapper_pattern.cpp:OnDetach()` - 状态转换282- `menu_pattern.cpp:OnClick` - 点击处理283- `menu_view.cpp:Create()` - 菜单创建流程284285**Solutions**:2861. **确保事件正确注册**287 - 检查 GestureEventHub 初始化288 - 验证 Pan event 注册289 - 确认 event hub 传递正确2902912. **检查菜单状态机**292 - 验证 OnModifyDone 时机293 - 确保 Menu 不在阻止状态294 - 检查 isShowing_ 状态2952963. **验证点击区域**297 - 检查是否有组件遮挡298 - 验证 hitTestStack 配置299 - 确认触摸事件传递3003014. **添加调试日志**302 ```cpp303 // 在点击处理中添加日志304 TAG_LOGI(AceLogTag::ACE_MENU, "OnClick called: menuId=%{public}d", menuId);305 ```306307---308309### Problem 2: 点击菜单立马就关闭了 (Menu Closes Immediately)310311**Symptoms**:312- 菜单打开后立即关闭313- 点击菜单后菜单消失314- 菜单闪现后消失315- 看到 "HideMenu" 日志紧接着 "ShowMenu"316317**Possible Causes**:3181. **状态机错误**319 - MenuWrapper 状态在 ATTACHING 和 DETACHED 间快速切换320 - OnDetach 被意外调用321 - 状态转换逻辑有缺陷3223232. **触摸事件冲突**324 - 点击事件触发两次325 - Hide 和 Show 事件冲突326 - Touch down 和 touch up 事件处理错误3273283. **Window 焦点问题**329 - Window 失去焦点导致菜单关闭330 - Focus change event 触发隐藏3313324. **超时配置错误**333 - Menu 超时时间设置为 0334 - Duration 太短导致立即关闭335336**Debug Steps**:3373381. **检查状态转换日志**339 ```bash340 # 查找快速的状态变化341 cat xxx.log | grep -E "ATTACHING|DETACHING" | head -20342 ```3433442. **检查 HideMenu 调用**345 ```bash346 # 查找谁调用了 HideMenu347 cat xxx.log | grep "HideMenu" | grep -B 5 "ShowMenu"348 ```3493503. **检查触摸事件**351 ```bash352 # 查找触摸事件353 cat xxx.log | grep "Touch"354 cat xxx.log | grep "Click"355 ```3563574. **检查窗口生命周期**358 ```bash359 # 查找子窗口创建和销毁360 cat xxx.log | grep "GetOrCreateMenuSubWindow"361 cat xxx.log | grep "RemoveMenuSubWindow"362 ```363364**Code Locations**:365- `menu_wrapper_pattern.cpp:OnDetach()` - 状态管理366- `menu_wrapper_pattern.cpp:HideMenu()` - 隐藏逻辑367- `menu_pattern.cpp` - 状态机实现368369**Solutions**:3701. **修复状态转换逻辑**371 - 添加状态转换日志372 - 添加转换条件检查373 - 防止非法状态转换3743752. **优化事件处理**376 - 添加事件去重逻辑377 - 防止 Show/Hide 冲突378 - 添加事件处理延迟3793803. **检查焦点管理**381 - 验证窗口焦点设置382 - 确认 focus 事件处理383 - 添加焦点状态日志3843854. **增加状态保护**386 ```cpp387 // 添加状态检查388 if (menuWrapperPattern->GetState() != MenuWrapperState::DETACHING) {389 TAG_LOGW(AceLogTag::ACE_MENU,390 "Invalid HideMenu call, current state=%{public}d",391 static_cast<int>(state));392 return;393 }394 ```395396---397398### Problem 3: 弹出菜单位置在屏幕左上角 (Menu Positioned at Top-Left)399400**Symptoms**:401- 菜单位置在屏幕左上角 (0,0)402- 菜单位置明显错误403- 菜单没有跟随触发器404- offset 计算错误405406**Possible Causes**:4071. **Offset 计算错误**408 - targetOffset 计算为 0409 - PositionOffset 未正确设置410 - 初始位置使用默认值4114122. **锚点配置错误**413 - anchorPoint 未设置414 - anchorPosition 使用默认值415 - 菜单锚到错误位置4164173. **MenuWindowRect 计算错误**418 - GetMenuWindowRectInfo 返回错误值419 - displayWindowRect 信息错误420 - 子窗口尺寸计算失败4214224. **Placement 配置未生效**423 - UpdateMenuPlacement 没有被调用424 - placement 属性被忽略425 - AlignRule 配置错误426427**Debug Steps**:4284291. **检查位置相关日志**430 ```bash431 # 查找菜单位置计算432 cat xxx.log | grep "MenuOffset"433 cat xxx.log | grep "MenuPosition"434 cat xxx.log | grep "targetOffset"435 ```4364372. **检查窗口 Rect 信息**438 ```bash439 # 查找窗口矩形440 cat xxx.log | grep "MenuWindowRect"441 cat xxx.log | grep "DisplayWindowRectInfo"442 ```4434443. **检查 placement 配置**445 ```bash446 # 查找 placement 配置447 cat xxx.log | grep "placement"448 cat xxx.log | grep "anchor"449 ```450451**Code Locations**:452- `menu_layout_algorithm.cpp:3611-3659` - GetMenuWindowRectInfo453- `menu_layout_algorithm.cpp` - Offset 计算454- `menu_pattern.cpp` - PositionOffset 更新455- `menu_view.cpp:1627` - UpdateMenuPlacement456457**Solutions**:4581. **验证 Offset 计算**459 - 检查 targetOffset 是否正确460 - 验证 positionOffset 来源461 - 添加 offset 计算日志4624632. **检查锚点配置**464 - 验证 anchorPoint 设置465 - 检查 anchorPosition 属性466 - 确认锚点计算逻辑4674683. **验证 Placement**469 - 确保 UpdateMenuPlacement 被调用470 - 检查 AlignRule 配置471 - 验证 placement 类型4724734. **添加位置调试日志**474 ```cpp475 // 添加位置日志476 TAG_LOGI(AceLogTag::ACE_MENU,477 "Menu position: offset=(%{public}f,%{public}f), target=(%{public}f,%{public}f)",478 offsetX, offsetY, targetOffsetX, targetOffsetY);479 ```480481---482483### Problem 4: 菜单弹出方向不对 (Menu Direction Incorrect)484485**Symptoms**:486- 菜单方向错误(应上弹却下弹)487- 菜单与触发器方向不匹配488- 子菜单展开方向错误489- 菜单在错误侧弹出490491**Possible Causes**:4921. **Direction 参数错误**493 - fontSize 或 direction 参数配置错误494 - menuDirection 枚举值不正确495 - 箭头绘制方向错误4964972. **Placement 计算错误**498 - placement 类型判断错误499 - Top/Bottom/Left/Right 混淆500 - AlignRule 应用不正确5015023. **Target 位置计算错误**503 - 触发器位置获取错误504 - TargetOffset 使用错误值505 - 相对位置计算符号错误5065074. **布局算法方向错误**508 - Column/Row 方向设置错误509 - crossAxis 配置错误510 - mainAxisSize 设置错误511512**Debug Steps**:5135141. **检查方向相关配置**515 ```bash516 # 查找方向配置517 cat xxx.log | grep -E "direction|font|arrow"518 ```5195202. **检查 placement 配置**521 ```bash522 cat xxx.log | grep "placement"523 cat xxx.log | grep "AlignDirection"524 ```5255263. **检查布局方向**527 ```bash528 cat xxx.log | grep "mainAxisSize"529 cat xxx.log | grep "crossAxis"530 ```531532**Code Locations**:533- `menu_pattern.cpp` - Direction 配置534- `menu_layout_algorithm.cpp` - Placement 计算535- `menu_item/` - 菜单项布局536537**Solutions**:5381. **验证 Direction 参数**539 - 检查 fontSize API 调用540 - 验证方向枚举值541 - 检查箭头绘制逻辑5425432. **修正 Placement 计算**544 - 确保 placement 类型正确545 - 检查 Top/Bottom 判断逻辑546 - 验证对齐规则5475483. **检查目标位置**549 - 验证 trigger 组件位置550 - 检查 targetOffset 计算551 - 确认相对位置方向5525534. **添加方向调试日志**554 ```cpp555 TAG_LOGI(AceLogTag::ACE_MENU,556 "Menu direction: placement=%{public}d, direction=%{public}d",557 placement, direction);558 ```559560---561562### Problem 5: 菜单没有避让挖坑/导航条 (Menu Overlaps System UI)563564**Symptoms**:565- 菜单被导航栏遮挡566- 菜单覆盖状态栏567- 菜单没有考虑系统 UI 安全区域568- 菜单部分在屏幕外569570**Possible Causes**:5711. **SafeArea 未应用**572 - GetSafeArea() 没有被调用573 - SafeArea insets 没有传递到布局574 - system_safe_area 属性未设置5755762. **Window Rect 计算错误**577 - displayWindowRect 没有考虑 safe area578 - Window 位置和尺寸计算错误579 - Cutout state 未应用5805813. **Z-Order 问题**582 - 菜单 window 层级错误583 - Window type 不是 PANEL 类型584 - Z-order 配置不正确5855864. **Maximize 设置错误**587 - LayoutFullScreen 使用错误588 - Window mode 设置为 FULLSCREEN 而非 FLOATING589 - 布局约束配置错误590591**Debug Steps**:5925931. **检查 SafeArea 相关日志**594 ```bash595 cat xxx.log | grep -i "safe|safeArea"596 ```5975982. **检查 Window Mode**599 ```bash600 cat xxx.log | grep "LayoutFullScreen"601 cat xxx.log | grep "WindowMode"602 ```6036043. **检查 Window Rect**605 ```bash606 cat xxx.log | grep "DisplayWindowRectInfo"607 ```608609**Code Locations**:610- `subwindow_manager.cpp` - Window 创建611- `menu_layout_algorithm.cpp` - SafeArea 应用612- Menu wrapper - Window 模式设置613614**Solutions**:6151. **应用 SafeArea 约束**616 - 确保 GetSafeArea() 被调用617 - 将 safe area 传递给布局算法618 - 设置 system_safe_area 属性6196202. **调整 Window Mode**621 - 使用 FLOATING 或 PANEL 类型622 - 避免 FULLSCREEN 模式623 - 设置合适的窗口属性6246253. **修正 Window Rect 计算**626 - 在窗口 rect 中减去 safe area627 - 确保菜单在可见区域内628 - 验证 cutout 处理6296304. **验证 Z-Order**631 - 检查 window type 配置632 - 确保菜单在正确层级633 - 验证与系统 UI 的关系634635---636637### Problem 6: 菜单弹出宽度为0/高度为0 (Menu Width/Height is 0)638639**Symptoms**:640- 菜单宽度计算为 0641- 菜单高度计算为 0642- Menu 显示异常窄或不显示643- displayWindowRectInfo 返回 0 值644645**Possible Causes**:6461. **异步初始化未完成**647 - GetDisplayWindowRectInfo 在 pipeline ready 前调用648 - displayWindowRect 还未初始化649 - 异步获取 display 信息时机错误6506512. **Pipeline Context 来源错误**652 - 使用了 subwindow 的 context 而非 main window653 - Context 类型判断错误654 - PipelineContext 初始化时机问题6556563. **MenuParam 配置错误**657 - fontSize 参数未解析658 - MenuParam 传递错误659 - 属性值未正确设置6606614. **计算公式错误**662 - menuMaxWidthRatio 计算为 0663 - displayWidth 乘以错误系数664 - theme 返回值使用错误665666**Debug Steps**:6676681. **检查 displayWidth 相关日志**669 ```bash670 # 查找宽度计算671 cat xxx.log | grep "displayWidth"672 cat xxx.log | grep "displayWindowRect.Width"673 cat xxx.log | grep "menuMaxWidthRatio"674 ```6756762. **检查 MenuParam**677 ```bash678 cat xxx.log | grep "MenuParam"679 cat xxx.log | grep "fontSize"680 ```6816823. **检查 Pipeline Context**683 ```bash684 cat xxx.log | grep "PipelineContext"685 cat xxx.log | grep "GetMainPipelineContext"686 ```687688**Code Locations**:689- `menu_layout_algorithm.cpp:920-966` - UpdateChildConstraintByDevice690- `menu_layout_algorithm.cpp:3618` - GetMenuWindowRectInfo691- `menu_pattern.cpp` - MenuParam 处理692- Theme 相关 - menuMaxWidthRatio 配置693694**Solutions**:6951. **添加初始化检查**696 ```cpp697 // 在 GetMenuWindowRectInfo 中添加检查698 auto displayWidth = displayWindowRectInfo.Width();699 if (displayWidth <= 0.0f) {700 TAG_LOGE(AceLogTag::ACE_MENU,701 "Invalid displayWidth=%{public}f, waiting for async init",702 displayWidth);703 return menuWindowRect;704 }705 ```7067072. **验证 Context 来源**708 - 检查是否应该使用 main window context709 - 验证 PipelineContext 类型710 - 添加 context 来源日志7117123. **延迟宽度计算**713 - 在异步初始化完成前使用默认宽度714 - 添加 ready 状态检查715 - 防止使用未初始化的值7167174. **添加异步初始化日志**718 ```cpp719 TAG_LOGI(AceLogTag::ACE_MENU,720 "Async display init: displayWidth=%{public}f, ready=%{public}d",721 displayWidth, IsDisplayReady());722 ```723724---725726## Log Enhancement Reference727728### Key Logging Patterns729730**1. State Transition Logging**731```cpp732TAG_LOGI(AceLogTag::ACE_SUB_WINDOW,733 "Subwindow state transition: %{public}d -> %{public}d",734 static_cast<int>(oldState), static_cast<int>(newState));735```736737**2. Value Context Logging**738```cpp739TAG_LOGI(AceLogTag::ACE_MENU,740 "Calculation: displayWidth=%{public}f, menuMaxWidthRatio=%{public}f, result=%{public}f",741 displayWidth, menuMaxWidthRatio, menuMaxWidth);742```743744**3. Code Path Logging**745```cpp746TAG_LOGI(AceLogTag::ACE_MENU,747 "GetMenuWindowRectInfo: host=%{public}p, menuId=%{public}d, targetTag=%{public}d, targetNodeId=%{public}d",748 host.Get(), menuPattern->GetMenuId(), targetTag_, targetNodeId_);749```750751**4. Error Context Logging**752```cpp753if (displayWidth <= 0.0f) {754 TAG_LOGE(AceLogTag::ACE_MENU,755 "Invalid displayWidth=%{public}f, expected>%{public}f",756 displayWidth, expectedWidth);757 return;758}759```760761### Critical Variables to Log762763**For Width/Height Issues**:764- `displayWindowRectInfo.Width()` / `Height()`765- `menuMaxWidth` / `menuMaxHeight`766- `menuMaxWidthRatio` / `menuMaxHeightRatio`767- `theme->GetMenuMaxWidthRatio()`768- `pipeline->GetDisplayWindowRectInfo()`769770**For Subwindow Issues**:771- `subwindow->GetDetachState()`772- `subwindow->GetShown()`773- `subwindow->GetRect().GetSize()`774- `instanceId` / `searchKey.ToString()`775776**For Layout Issues**:777- `menuWindowRect` (all fields)778- `targetOffset_` / `targetSize_`779- `GetMenuWindowRectInfo()` return value780- `placement` / `anchorPosition`781782## Quick Reference Code Locations783784| Problem Type | File | Line(s) | Function | Key Variables |785|-------------|------|----------|----------|---------------|786| Click issues | `menu_wrapper_pattern.cpp` | - | `OnDetach` / `OnAttach` | `state_` |787| Auto-close | `menu_pattern.cpp` | - | State machine | `isShowing_` |788| Position (top-left) | `menu_layout_algorithm.cpp` | 3611-3659 | `GetMenuWindowRectInfo` | `menuWindowRect` |789| Direction | `menu_pattern.cpp` | - | `direction_` / `placement` | - |790| Safe area | `subwindow_manager.cpp` | - | Window creation params | - |791| Width=0/Height=0 | `menu_layout_algorithm.cpp` | 920-966 | `UpdateChildConstraintByDevice` | `displayWidth` |792793## Log Filtering Commands794795**Extract all Menu-related logs**:796```bash797# Comprehensive Menu logs798grep -E "ACE_MENU|ACE_SUB_WINDOW|ACE_OVERLAY" xxx.log > menu_debug.log799800# Width-specific logs801grep -E "DisplayWindowRectInfo|menuMaxWidth|displayWidth" xxx.log802803# Subwindow recreation logs804grep -E "recreate subwindow|DETACHING|MenuWindowState" xxx.log805806# Positioning logs807grep -E "MenuOffset|MenuPosition|targetOffset|placement" xxx.log808809# Click/Event logs810grep -E "OnClick|TouchEvent|GestureEvent" xxx.log811```812813**Filter by specific instance**:814```bash815# For specific container ID816grep "instanceId: 123" xxx.log817818# For specific menu node819grep "menuId: 456" xxx.log820```821822## Best Practices823824### Log Enhancement Principles825826**DO**:827- ✅ Add context - log relevant variable values828- ✅ Log state transitions - old → new829- ✅ Use appropriate log level - INFO for normal, WARN for unexpected, ERROR for failures830- ✅ Include identifiers - node IDs, instance IDs831- ✅ Log calculations - input values and results832- ✅ Minimal changes - Only add logging, don't modify logic833- ✅ Use existing macros - TAG_LOGI/W/E with correct tags834- ✅ Test compilation - Verify syntax before applying835- ✅ Document changes - Note what and why for each log836837**DON'T**:838- ❌ Log without context - just "entered function"839- ❌ Over-log - excessive logging in loops840- ❌ Log sensitive data - user information, tokens841- ❌ Speculate - log actual values only842- ❌ Modify logic - Only add logging statements843844### Patch Generation Guidelines8458461. **Minimal Changes** - Only add logging, don't modify logic8472. **Preserve Formatting** - Follow existing code style8483. **Use Existing Macros** - TAG_LOGI/W/E with correct tags8494. **Test Compilation** - Verify syntax before applying8505. **Document Changes** - Note what and why for each log8516. **Contextual Logging** - Include surrounding code state in logs852853### Analysis Workflow8548551. **Gather baseline** - Collect logs without issue if possible8562. **Apply patch** - Add targeted logging8573. **Reproduce issue** - Trigger problem with enhanced logging8584. **Extract relevant logs** - Filter specific log tags8595. **Trace execution flow** - Follow log sequence through code8606. **Identify root cause** - Find where unexpected behavior occurs8617. **Implement fix** - Address identified issue8628. **Verify resolution** - Confirm fix works, remove debug logs if needed863864## Integration with Other Skills865866This skill complements:867- **compile-analysis** - For performance issues in Menu code868- **build-error-analyzer** - If Menu changes cause build failures869- **xts-component-test** - For writing Menu test cases870871## Version History872873- **0.2.0** (2026-02-12): 新增6个常见问题分析874 - 💫 添加点击无响应问题分析875 - 💫 添加菜单自动关闭问题分析876 - 💫 添加菜单位置左上角问题分析877 - 💫 添加菜单方向不对问题分析878 - 💫 添加菜单避让导航条问题分析879 - 💫 添加宽度/高度为0问题分析880 - 📝 为每个问题提供详细调试步骤和解决方案881 - 🎯 扩展触发关键词覆盖常见用户问题882883- **0.1.0** (2026-02-12): 初始版本884 - ✨ 完整的 Menu 组件调试 skill885 - 📝 覆盖宽度、子窗口、布局、崩溃等4大类问题886 - 🔧 提供系统化调试工作流程887 - 📊 包含关键代码位置和变量参考888 - 🎯 自动化日志增强补丁生成