Closed Bug 2091233 Opened 14 days ago Closed 12 days ago

Optimize requestUiThreadCallback

Categories

(GeckoView :: General, defect)

All
Android
defect

Tracking

(firefox161 fixed, firefox162 fixed)

RESOLVED FIXED
162 Branch
Tracking Status
firefox161 --- fixed
firefox162 --- fixed

People

(Reporter: m_kato, Assigned: m_kato)

References

(Blocks 1 open bug)

Details

Attachments

(2 external files)

No description provided.

When posting a Runnable task to the Android UI thread, we use
GeckoThread.requestUiThreadCallback(). Finally, RunAndroidUiTasks
will be called to run tasks in the queue. requestUiThreadCallback() is
called multiple times, and then postDelayed() is called multiple times
too, even if we have already scheduled a task to run
RunAndroidUiTasks. This is not necessary, and we can optimize it by
only calling postDelayed() once.

Android 17's new concurrent message queue always allocates a Message
object, not recycling it. So we should avoid calling postDelayed()
multiple times to reduce memory allocation.

Status: NEW → RESOLVED
Closed: 12 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: There is a lot of OOM crash by Message.obtain with Android 17. This fix reduces to allocate Message object. This will occur when the Android UI thread is busy.
  • Code covered by automated testing?: unknown
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Before this fix, we always dispatch a task to Android UI thread. But after this, we don't dispatch a task if any task is already queued.
  • String changes made/needed?: No
  • Is Android affected?: yes
Attachment #9682313 - Flags: approval-mozilla-beta?

When posting a Runnable task to the Android UI thread, we use
GeckoThread.requestUiThreadCallback(). Finally, RunAndroidUiTasks
will be called to run tasks in the queue. requestUiThreadCallback() is
called multiple times, and then postDelayed() is called multiple times
too, even if we have already scheduled a task to run
RunAndroidUiTasks. This is not necessary, and we can optimize it by
only calling postDelayed() once.

Android 17's new concurrent message queue always allocates a Message
object, not recycling it. So we should avoid calling postDelayed()
multiple times to reduce memory allocation.

Original Revision: https://phabricator.services.mozilla.com/D341244

Attachment #9682313 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: