Introducing the Construct 2 Debugger and Profiler

1
Official Construct Post
Ashley's avatar
Ashley
  • 2 Oct, 2013
  • 825 words
  • ~3-6 mins
  • 2,307 visits
  • 0 favourites

Defects are a fact of life when developing a game or app, and figuring out how to fix things can take up a significant amount of project development time. A debugger is a tool specifically designed to help with this, by clearly showing everything that is happening and allowing you to solve problems much more quickly. With the latest stable update r146, Construct 2 now includes its own debugger, enabling faster and easier development of professional-grade games and apps. This is a free update for all existing Construct 2 users.

Debugger features

The Construct 2 debugger runs in the browser, powered entirely by the same HTML5 technology that the games themselves run on. A panel appears alongside the game with lots of tools and information to help you learn more about your project.

The basic usage of the debugger allows you to pick an object, and browse its state while seeing the instance highlighted in the game. You can either see the values changing in real-time, or pause the game and browse through the values at your leisure.

It goes a lot further than that though! Some more of its features include:

  • Being able to pop-out in to a separate window - useful for multi-monitor setups
  • Controls to pause and resume the game
  • Step the game frame-by-frame when paused
  • Save and load the entire state of the game to be able to repeatedly test a single section of the game, taking advantage of the savegames system
  • View a real-time summary of performance details
  • Browse a list of all objects in the game, and inspect information about them, including their instance variable values and behavior states
  • Edit any value at any time and see the change take effect in real-time
  • Add individual values to the 'Watch' tab, creating your own space with just the values you're interested in

And that's still not quite it - the profiler and event breakpoints let you go even further.

Profiler

Profilers are tools that show you a breakdown of how much processing time is spent in each area of your project. In the debugger you can also switch to the Profiler tab to see detailed performance information about the game, broken down right the way to how much time is being spent in individual event groups.

The profiler works by using high-resolution Javascript timers to measure the time spent in each area of the engine: event sheets and groups, physics simulation, draw calls (from the CPU), and other engine tasks. Note that the profiler only shows a breakdown of CPU time on the main thread; the time the GPU takes to actually finish rendering is not shown, nor are other CPU tasks happening on other threads such as processing audio (or in some cases the actual draw calls). Still, it can provide an at-a-glance summary of some areas that could potentially be performance problems, especially within your event sheets, and these are often the main problems anyway.

We have more performance advice in our Performance Tips manual entry, as well as a warning against unnecessary optimisation in our blog post Optimisation: don't waste your time. Remember, if your game already runs fast enough on all your target platforms, you don't need to optimise it! Your time will be better spent on making your project better.

Breakpoints

Perhaps the most advanced feature of the debugger is the ability to set breakpoints on events. Breakpoints cause the debugger to pause when a specific event block, condition or action is reached at runtime. They appear as a pause icon, as shown below.

You can even step through the event sheet event-by-event, condition-by-condition, and action-by-action, watching the debugger values update as each part of the event runs. Construct 2 highlights the part of the event that is about to run.

This is the ultimate way to learn how your events work in detail - and perhaps even identify the single condition or action at the heart of an issue.

Unfortunately due to the architecture of the Construct 2 engine, breakpoints cannot be set anywhere inside triggers or looping events. However it may be possible to remedy this in future, and being able to step through most events can still be incredibly valuable.

Free edition limits

Users of the Free edition can start up the debugger, and use it to browse the state of games. However editing values, the 'Watch' tab, the profiler, and the ability to use breakpoints are only available with a license. Purchase a license and take advantage of these powerful new capabilities!

Find out more

You can learn more about how these features work in the manual entries on the debugger and breakpoints, which includes specifics on how to use these features from Construct 2. Learn more about Construct 2 itself in the Construct 2 section of our site, and as always, stay tuned for more updates with new exciting features still to come!

Subscribe

Get emailed when there are new posts!