diff options
author | Tony Mak <tonymak@google.com> | 2020-06-08 15:37:08 +0100 |
---|---|---|
committer | Tony Mak <tonymak@google.com> | 2020-06-10 15:35:04 +0100 |
commit | 8cb5546c37eba900031f0060602e2e78c83c92f3 (patch) | |
tree | a89d500311c6a999f6b7c1e2a2d878274a47ab18 /rs/java/android/renderscript/ProgramFragmentFixedFunction.java | |
parent | a38a553c1617312433a9c0e27fdaafee27e3a359 (diff) |
Limit the maximal number of pending requests in TCMS
Introduce FixedSizeQueue, a simple wrapper of ArrayDeque that only has
a limited size. This avoids the situation that TCMS caches a lot of
pending request in the queue while it is not going to bind to a TCS
anytime soon. When the request is removed from the queue, we notify
the client that the request is failed.
Also, we now limit the max amount of sessions in the cache.
We already have two measures to avoid the leak of sessions, i.e. Cleaner
and linkToDeath, but just in case.
Also, fixed an issue that onDestoryTcSession() is called on the
wrong TC if the TCS is not bound yet. This is an example of the
problematic running sequence:
1. TCS is not bound
2. onCreateTextClassificationSession is called
3. onDestory() is called. TCMS finds out which TC to call by looking
at session cache.
However, sessionCache does not contains the record that we need
because we do not update it until the service is bound.
4. TCS is now bound.
5. onCreateTextClassificationSession is forwared to the right TC.
6. onDestory is forwared to the default TC, which is the default
if we don't know which TC to call on.
The solution is just to update sessionCache as soon as
onCreateTextClassificationSession is invoked.
BUG: 156683847
Test: atest FixedSizeQueueTest
Test: Revert ag/11734845. Send a lot of messages that won't trigger
suggestConversationActions. Check the output of
"dumpsys textclassification", make sure the pending queue size
is always <= the limit.
Test: m mts && mts-tradefed run mts-extservices
Change-Id: Ib2e3e0d553e703ea759144bc9b38fec0d87de719
Diffstat (limited to 'rs/java/android/renderscript/ProgramFragmentFixedFunction.java')
0 files changed, 0 insertions, 0 deletions