Skip to content
Commit b7dfb9b8 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Break a cross process ref chain in spell checker

This is a follow up CL to my CL [1], which unintentionally introduced
a cross process reference chain in callback objects among the
following three processes:
 * spell checker client process X
 * system server process Y
 * spell checker service process Z

This is a common problem when implementing cross process callbacks
because we need to garbage collect processes Z, Y, X, in that order to
fully clean up objects that are directly or indirectly referenced from
callback objects in process X and Y.

Fortunately our spell checker API design allows us to mitigate this
problem by internally breaking references from those callback objects
to other heavyweight objects, like we often do so almost everywhere in
the system, because the system knows the entire lifecycle of callback
objects around spell checker.

android.view.textservice.SpellCheckerSession$InternalListener in the
process X already does this so we don't need to worry about reference
chains beyond that objects.

TextServicesManagerService.ISpellCheckerServiceCallbackBinder, which
was introduced by my previous CL [1], is however problematic because
it (indirectly) holds strong references to other objects including
binder proxies to the process X.  This CL addresses this part by
breaking references from ISpellCheckerServiceCallbackBinder to other
objects in TSMS with WeakReference, like we usually do so in the
system.

 [1]: Iee04f4c0e2d248041d01c528344b191b9875d122
      6008106a

Bug: 109701487
Test: Manually verified with hprof heap dump that
      ISpellCheckerServiceCallbackBinder no longer has strong
      reference chains to other heavy weight objects.
Change-Id: Icdf11e5be07abbe71bdf8af537959957d760b80d
parent 381f6287
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment