⚡ [Performance] Avoid object allocation in TouchButtonView.onDraw#10
⚡ [Performance] Avoid object allocation in TouchButtonView.onDraw#10SirDank wants to merge 1 commit into
Conversation
Moved `RectF` allocation in `TouchButtonView.onDraw` to a class member and updated it with `.set()` instead of creating a new object every frame. This avoids garbage collection overhead during animations. Co-authored-by: SirDank <52797753+SirDank@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Merged in perf category PR commit |
💡 What: Moved
RectFallocation inTouchButtonView.onDrawto a class member and updated it with.set()instead of creating a new object every frame.🎯 Why: Object allocations in
onDraware a well-known Android performance anti-pattern. SinceonDrawcan be called 60 times a second during animations, allocating objects inside it triggers garbage collection more frequently, leading to frame drops. Moving the allocation to initialization and mutating the object directly resolves this overhead.📊 Measured Improvement: I was unable to show a meaningful performance improvement because the Gradle build fails from missing heavy assets (lwjgl) that cannot be easily built in the sandbox environment, making it impractical to run a full device-based or Robolectric-based benchmark test. However, this is a standard and universally accepted performance optimization for Android Views.
PR created automatically by Jules for task 12663536340180543958 started by @SirDank