Troubleshooting

Tips and techniques for debugging RPGReact games during development.

Browser DevTools

Accessing DevTools

In NW.js (desktop):

// Add to package.json
{
  "chromium-args": "--remote-debugging-port=9222"
}

Then open Chrome and navigate to chrome://inspect or press F12 in-game (if enabled).

In browser (web build): Press F12 or right-click → Inspect

Console Logging

Add debug logs to your components:

useEffect(() => {
  console.log('[MyComponent] Mounted', props);
  return () => console.log('[MyComponent] Unmounted');
}, []);

useEffect(() => {
  console.log('[MyComponent] Props changed', props);
}, [props]);

Common Console Errors

"Cannot read property 'X' of undefined"

  • Game data not loaded yet

  • MobX observable accessed before initialization

  • Check if RPGBridge.IsInitialized() is true

"Maximum update depth exceeded"

  • Infinite render loop

  • State update in render function

  • Fix: Move state updates to useEffect or event handlers

"Warning: Can't perform a React state update on an unmounted component"

  • Async operation completes after unmount

  • Fix: Cancel async operations in useEffect cleanup

React DevTools

Install React DevTools extension for Chrome/Firefox.

Features:

  • Inspect component tree

  • View props and state

  • Track component re-renders

  • Profile performance

Highlight renders: Settings → Highlight updates when components render

MobX DevTools

Spy on observables

Track reactions

Common Issues & Solutions

Issue: Stale State in Callbacks

Symptom: Values in setTimeout/animation loops are outdated

Debug:

Solution: Use refs or functional updates

Issue: Component Not Re-rendering

Debug: Check if using MobX observer:

Issue: Memory Leaks

Detect:

  1. Open Chrome DevTools → Memory tab

  2. Take heap snapshot

  3. Play game for a while

  4. Take another snapshot

  5. Compare - detached DOM nodes or growing arrays indicate leaks

Common causes:

  • Event listeners not removed

  • Animation frames not canceled

  • Timers not cleared

  • RPGBridge handlers not removed

Fix pattern:

Issue: Performance Problems

Profile:

  1. DevTools → Performance tab

  2. Click Record

  3. Perform slow action

  4. Stop recording

  5. Analyze flame graph

Common causes:

  • Expensive calculations in render

  • Missing useMemo/useCallback

  • Too many observers

  • Large lists without virtualization

Solution:

Debugging Specific Systems

Battle System

Input System

Asset Loading

Development Workflow

Hot Reload Setup

For React changes:

For override changes: Restart RPG Maker MZ playtest

Test Specific Screens

Create a test map with events that trigger specific screens:

Mock Data for Testing

Logging Best Practices

Structured Logging

Conditional Logging

Performance Logging

See Also

Last updated