Skip to content

Latest commit

Β 

History

History
78 lines (59 loc) Β· 2.15 KB

File metadata and controls

78 lines (59 loc) Β· 2.15 KB

Xposed Module Performance & Impact

Measuring how Xposed modules affect device performance.

Impact factors

  • Scoped modules (target single app) β€” minimal impact
  • System-wide modules β€” higher overhead, especially with hooks in frequently-called methods
  • Callback count β€” each hook/callback adds latency

Benchmark tools

Built-in Xposed logging

# View Xposed module load time
adb shell dumpsys | grep -i xposed

# Check Zygisk timing
adb logcat | grep -i "zygisk\|lsposed"

Android Profiler

  1. Open Android Studio β†’ Profiler
  2. Select device and process
  3. Monitor CPU, memory during app launch
  4. Compare with modules enabled vs disabled

Custom profiling in module

Java.perform(function() {
    var start = Java.use("java.lang.System").nanoTime();
    
    // Your hook
    var target = Java.use("com.example.Class");
    target.method.implementation = function() {
        console.log("[Perf] Method called");
        return this.method.call(this);
    };
    
    var elapsed = (Java.use("java.lang.System").nanoTime() - start) / 1000000;
    console.log("[Perf] Hook setup took: " + elapsed + "ms");
});

Performance checklist

  • βœ… Scope module to specific apps if possible
  • βœ… Avoid hooking frequently-called methods (onCreate, onDraw, etc.)
  • βœ… Use reflection sparingly β€” cache references
  • βœ… Test on low-end devices (if targeting them)
  • βœ… Monitor battery impact (logcat + Battery Historian)
  • βœ… Profile memory leaks (if holding references)

Slowest modules (typical impact)

  • Clipboard monitors β€” +2-5% CPU
  • Animation tweaks β€” +1-3% depending on hook depth
  • Permission overrides β€” minimal if scoped
  • Inline encryption logging β€” +5-15% for crypto ops

Optimal hook targets

❌ Avoid:

  • onCreate, onResume, onDraw (called frequently)
  • View.inflate, Thread constructors
  • System.loadLibrary (affects startup)

βœ… Better:

  • Lifecycle callbacks (onStart, onPause)
  • Specific UI update methods
  • User-triggered methods

Test with trace

adb shell perfetto -c perfetto_config.pb -o /tmp/trace.pb

# Analyze in Perfetto UI: https://ui.perfetto.dev