Understanding the GameSalad Runtime Engine

Scene and Actor Lifecycle

GameSalad manages scenes as containers and actors as behavior-bound objects within them. At runtime, each actor's behaviors are executed in a loop. Performance drops occur when too many actors run complex logic simultaneously, overwhelming the device's CPU or GPU.

Preview vs. Device Runtime

The desktop preview uses your local CPU and memory, which are significantly more powerful than a mobile device. This disparity means performance issues only become visible during device testing or after publishing.

Root Causes of Scene Lag

1. Excessive Rule Evaluations

Nested rules and frequently firing Every or Timer behaviors cause behavior queue bloat.

If  = value
  Timer: Every 0.01 seconds
    Change Attribute: self.X = self.X + 1

Such rules are CPU-intensive, especially when applied across dozens of actors.

2. Large Asset File Sizes

Uncompressed images and oversized audio assets increase scene load time and memory usage. On mobile devices with limited RAM, this leads to frame drops and input lag.

3. Overlapping Collision Shapes

Actors with circular or polygonal collision shapes constantly calculating physics with overlapping boundaries degrade performance drastically.

4. Global Attribute Polling

Frequent referencing of global game attributes inside multiple actor behaviors increases runtime lookup cost.

Diagnostics and Testing Workflow

Step 1: Use the Viewer App

Deploy your game to the GameSalad Viewer on an actual device to detect real performance issues.

Step 2: Enable Performance Monitoring

Use Display Text behavior to monitor game.Time or self.FrameRate to identify scene areas where FPS drops occur.

Step 3: Isolate the Scene

Duplicate the lagging scene and gradually remove actors or rules until performance improves. This binary isolation helps pinpoint the cause.

Fixing the Issue: Step-by-Step

1. Optimize Timers and Rules

  • Replace Timer: Every 0.01 with constrained attributes or interpolation where possible.
  • Use Change Attribute instead of Rule + Timer for one-time events.

2. Compress Assets Before Import

Use tools like TinyPNG and Audacity to compress images and convert audio to .ogg format with reduced bitrate.

3. Flatten Actor Behavior

Consolidate rules to avoid nested logic. Group common logic into tables or utility actors with shared roles.

4. Minimize Global Attribute Usage

Use self or scene attributes instead of game attributes wherever possible.

5. Adjust Collision Detection Settings

Use rectangle collisions instead of complex shapes. Disable physics on actors that don't need it.

Best Practices for Performance Optimization

  • Asset Budgeting: Limit image files to under 500 KB and audio to under 1 MB.
  • Behavior Efficiency: Use interpolation or expressions instead of repeated rules.
  • Scene Complexity: Cap active actors on screen to under 100 for mobile targets.
  • Modular Design: Use tables for state management instead of nested conditions.
  • Device Testing: Always test on low-end devices to find performance ceilings.

Conclusion

GameSalad is excellent for quick game development, but optimization becomes crucial as projects grow. By understanding the runtime architecture, minimizing expensive behavior constructs, and compressing assets, developers can achieve smooth performance even on low-spec devices. The key is to treat preview performance as an approximation and always validate optimizations in real device contexts.

FAQs

1. Why does my game lag only after publishing?

Because preview mode runs on a powerful machine. Publishing reveals mobile limitations like memory and CPU constraints.

2. Can I dynamically load/unload actors in GameSalad?

No. GameSalad loads all actors in a scene at once. Use layering and visibility toggles to manage complexity.

3. How can I test frame rate in GameSalad?

Use Display Text to show self.FrameRate on-screen during Viewer testing.

4. What is the ideal resolution for assets?

Design assets at 2x resolution for Retina support, but compress them to under 500 KB before import.

5. Is GameSalad suitable for complex games?

Yes, but only with careful performance planning. Large scenes, many actors, and rich assets require optimization discipline.