| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The listener was removed from an OnGlobalLayoutListener, which only runs if a layout pass follows the draw. On a static screen it stayed registered and ran on every frame, retaining its callback. Post the removal to the main thread instead so it always happens. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
📲 Install BuildsAndroid
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
📜 Description
FirstDrawDoneListener now removes itself by posting the removal to the main thread. Before, it waited for the next global layout.
💡 Motivation and Context
You can't remove an OnDrawListener from inside onDraw (API 26+ throws). So the listener registered an OnGlobalLayoutListener and removed itself from there. But a draw isn't always followed by a layout pass. On a static screen, the listener stayed registered and ran on every frame (as a no-op), and it kept its callback reachable. That callback captures ActivityLifecycleIntegration and the ttid/ttfd spans. ActivityLifecycleIntegration registers a new listener on every onActivityResumed, so these could pile up on the decor view until the next layout.
It isn't a memory leak: everything is only reachable from the decor view's ViewTreeObserver and dies with the activity. The fix makes the removal happen every time and drops the extra layout listener.
💚 How did you test it?
Updated FirstDrawDoneListenerTest: the listener is now removed after onDraw without any layout pass.
📝 Checklist
🔮 Next steps
Consider registering only once per activity in ActivityLifecycleIntegration.onActivityResumed, instead of on every resume.
🤖 Generated with Claude Code