Mobile Optimization
Overview
Mobile-specific performance optimization for Android/iOS. Covers framerate targeting, resolution scaling, thermal throttling, and battery efficiency.
When to Use
- Use for Android/iOS builds
- Use when battery drain is high
- Use when device overheats
- Use for adaptive quality
- Use for low-end device support
Mobile Constraints
┌─────────────────────────────────────────────────────────────┐
│ MOBILE PERFORMANCE PYRAMID │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌────────┐ │
│ │ BATTERY│ │
│ └────┬───┘ │
│ ┌────────┴────────┐ │
│ │ THERMAL │ │
│ └────────┬────────┘ │
│ ┌─────────────┴─────────────┐ │
│ │ MEMORY │ │
│ └─────────────┬─────────────┘ │
│ ┌──────────────────┴──────────────────┐ │
│ │ CPU / GPU │ │
│ └─────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Key Settings
| Setting | Low Device | High Device |
|---------|:----------:|:-----------:|
| Target FPS | 30 | 60 |
| Resolution Scale | 0.7 | 1.0 |
| Shadow Resolution | 512 | 2048 |
| Texture Quality | Half | Full |
| MSAA | Off | 2x |
Optimization Techniques
| Technique | Impact | Implementation |
|-----------|:------:|----------------|
| Frame Rate Cap | High | Application.targetFrameRate |
| Resolution Scale | High | Screen.SetResolution |
| VSync | Medium | QualitySettings.vSyncCount |
| GPU Skinning | Medium | Player Settings |
| Texture Streaming | High | QualitySettings |
Best Practices
- ✅ Profile on actual device
- ✅ Use Adaptive Performance (Samsung)
- ✅ Implement quality presets
- ✅ Reduce draw calls (<100)
- ✅ Use texture atlases
- ❌ NEVER target 60fps on low-end
- ❌ NEVER ignore thermal throttling
- ❌ NEVER use max quality by default
Few-Shot Examples
Example 1: App Configuration
User: "Set up mobile performance."
Agent:
public class MobileConfig : MonoBehaviour
{
[Header("Performance")]
[SerializeField] private int _targetFPS = 60;
[SerializeField] private bool _enableVSync = true;
[SerializeField] private float _resolutionScale = 1f;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Initialize()
{
var config = new MobileConfig();
config.ApplySettings();
}
public void ApplySettings()
{
Application.targetFrameRate = _targetFPS;
QualitySettings.vSyncCount = _enableVSync ? 1 : 0;
if (_resolutionScale < 1f)
{
int width = (int)(Screen.width * _resolutionScale);
int height = (int)(Screen.height * _resolutionScale);
Screen.SetResolution(width, height, true);
}
}
}
Example 2: Adaptive Quality
User: "Auto-adjust quality based on FPS."
Agent:
public class AdaptiveQuality : MonoBehaviour
{
[SerializeField] private int _targetFPS = 30;
[SerializeField] private int _fpsThresholdLow = 25;
[SerializeField] private int _fpsThresholdHigh = 40;
private float _checkInterval = 5f;
private float _timer;
private float _avgFPS;
private void Update()
{
_avgFPS = Mathf.Lerp(_avgFPS, 1f / Time.deltaTime, 0.1f);
_timer += Time.deltaTime;
if (_timer >= _checkInterval)
{
AdjustQuality();
_timer = 0;
}
}
private void AdjustQuality()
{
int current = QualitySettings.GetQualityLevel();
if (_avgFPS < _fpsThresholdLow && current > 0)
{
QualitySettings.DecreaseLevel();
Debug.Log("Quality decreased");
}
else if (_avgFPS > _fpsThresholdHigh && current < QualitySettings.names.Length - 1)
{
QualitySettings.IncreaseLevel();
Debug.Log("Quality increased");
}
}
}
Example 3: Battery Saver Mode
User: "Add battery saving option."
Agent:
public void EnableBatterySaver(bool enabled)
{
if (enabled)
{
Application.targetFrameRate = 30;
QualitySettings.SetQualityLevel(0); // Lowest
Screen.brightness = 0.5f;
}
else
{
Application.targetFrameRate = 60;
QualitySettings.SetQualityLevel(2); // Medium
Screen.brightness = 1f;
}
PlayerPrefs.SetInt("BatterySaver", enabled ? 1 : 0);
}
Platform Specifics
- Android: Use Adaptive Performance SDK
- iOS: Check thermalState notifications
- Both: Test on min-spec devices
TDD Contract
⚠️ Legacy Skill — Refactor Pending
Este skill NO tiene tests automatizados aún. El siguiente boilerplate es un punto de partida.
// Escribe estos tests ANTES de implementar:
// Test 1: should [expected behavior] when [condition]
[Test]
public void MobileOptimization_Should{ExpectedBehavior}_When{Condition}()
{{
// Arrange
// TODO: Setup test fixtures
// Act
// TODO: Execute system under test
// Assert
Assert.Fail("Not implemented — write test first");
}}
// Test 2: should handle [edge case]
[Test]
public void MobileOptimization_ShouldHandle{EdgeCase}()
{{
// Arrange
// TODO: Setup edge case scenario
// Act
// TODO: Execute
// Assert
Assert.Fail("Not implemented");
}}
// Test 3: should throw when [invalid input]
[Test]
public void MobileOptimization_ShouldThrow_When{InvalidInput}()
{{
// Arrange
var invalidInput = default;
// Act & Assert
Assert.Throws<Exception>(() => {{ /* execute */ }});
}}
Pasos para completar el TDD:
- Descomenta los tests above
- Implementa la funcionalidad mínima para que compile
- Ejecuta los tests — deben fallar (RED)
- Implementa la funcionalidad real
- Verifica que los tests pasen (GREEN)
- Refactorea manteniendo los tests verdes
Nota: Este skill fue marcado como tdd_first: false durante la auditoría v2.0.1. La sección TDD fue agregada automáticamente pero requiere customización manual para reflejar el comportamiento real del skill.
Related Skills
@object-pooling-system- GC-free spawning@lod-occlusion-culling- Rendering optimization@memory-profiler-expert- Memory limits