42 Commits

Author SHA1 Message Date
Bo Liu
027b218847 Integrate HWUI with PerformanceHintManager
PerformanceHintManager.Session is in java, so add JNI and a HintSessionWrapper
class in HardwareRenderer. Then pass the two calls as two std::functions
into DrawFrameTask.

Note Session is created per HardwareRenderer, not global (per
RenderThread).

Session includes UI thread, render thread, and the thread pool.
Desired duration is from the intended start duration to the frame
deadline. Add an actual frame start time to compute

Add system properties:
debug.hwui.use_hint_manager to enable PerformanceHintManager
debug.hwui.target_cpu_time_percent to control percentage of frame time
  to be used for target cpu duration.

Test: Manual test that there are no crashes and values make sense.
Bug: 158791282
Change-Id: I83f25433c10daa20033803fb7c4ae45eab34f1d3
2021-04-10 10:21:17 -07:00
Jerome Gaillard
e218c69285 Replace CLOCK_MONOTONIC with SYSTEM_TIME_MONOTONIC
Using SYSTEM_TIME_MONOTONIC works for Android (where it translates to
CLOCK_MONOTONIC) and host targets, while CLOCK_MONOTONIC is not defined
on macOS.

Bug: 117921091
Test: existing tests should pass
Change-Id: I1fad472881830fb0701a320cf37319e083932ad4
2019-06-14 12:07:36 +00:00
John Reck
cfd929dffd Revert "Revert "Fix lifecycle issue in CommonPool""
This reverts commit 162305aaceca5f6cbaa03db1aa124f67e313612e.

Adjusted tests to ensure they pass on cf_x86

Bug: 129250875
Test: this on cf_x86 & blueline

Change-Id: Ic3245ec8db784ae356b7fa66dda9a2fc91c622ea
2019-04-08 16:30:22 -07:00
David James
162305aace Revert "Fix lifecycle issue in CommonPool"
This reverts commit 5ff61f32a78dca0c722c8ac2685874a26190ceed.

Reason for revert: causes global presubmit to be very flaky, see b/130081457
Fixes: b/130081457

Change-Id: I93aa5d6686cd6b5bf831766c9e47c291749526a9
2019-04-07 04:28:50 +00:00
John Reck
5ff61f32a7 Fix lifecycle issue in CommonPool
Destroy things more faster

Fixes: 129250875
Test: hwui_unit_tests
Change-Id: I7e060fcb61f5321dd9e68a3ee4a01868033b3fc3
2019-04-04 16:05:10 -07:00
John Reck
322b8ab774 Remove old TaskManager system
Replace it with a newer, fancier, WorkQueue-inspired
one that's just a global common thread pool.

Test: hwuiunit passes
Change-Id: Ib5d03104a08bbac9a4ec67a1bfc0db2b35d6700f
2019-03-18 09:34:11 -07:00
John Reck
352e9f0b7a Add missing Looper::setForThread
Unlike the Java Looper the native one requires manually
setting of the looper for a particular thread.

So... do that.

Fixes: 124467483
Test: really good guess
Change-Id: Iac9b4a052e79228aea5760262996729d8dadb1b8
2019-02-14 16:26:08 -08:00
Stan Iliev
978d5321b4 Fix RenderThread and worker thread names used by tools
Test: collected systrace and RenderThread hwuiTask1/2 shown
Change-Id: I1114ff72a7ed8c9dc86a64ebd15ca783d1b2ff08
2019-02-06 12:02:28 -05:00
Stan Iliev
80dbc35555 Tell JVM to not wait for HWUI worker threads upon shutdown
RenderThread is setup as a daemon thread, which allows JVM to
exit without waiting on it. This CL does same setup for HWUI
worker threads, which offload work from the RenderThread.
This fixes an issue exposed by Vulkan pipeline, which is pushing
different loads to the worker threads and causing some java tests
to hang on exit. This is not a Vulkan specific issue, because GL
also hangs if worker thread is started.

Bug: 123374538
Test: Ran DismissDialogsInstrumentation test
Change-Id: Ie4ee94737ced975323a0792f57f8426c958e8056
2019-02-05 16:26:58 -05:00
John Reck
6104cea3fb Fix leak/crash in exit
Bug: 120440607
Test: hwuimacro32 doesn't crash
Change-Id: I35b7a924e338efb314f07b923ba22ffcf98f75ee
2019-01-10 15:34:49 -08:00
Chris Blume
7b8a808b7d Remove ; from closing namespaces in libs/hwui
When closing a namespace a } is sufficient. It doesn't need to be };
like closing a class or enum.

Within frameworks/base/libs/hwui there is a mix between } and }; when
closing a namespace. There are even mixes between a .h and the
corresponding .cpp files.

In a separate CL I was asked to not close with };. That was a good
comment. I adopted the style from nearby code. This CL cleans up the
nearby code.

Test: I made sure the code still built as expected.
Change-Id: Ieb314a4f48d6e33752463f3be4361fdc9be97482
2018-12-03 16:05:14 -08:00
John Reck
e170fb6686 A better HW Bitmap uploader
Move all HW bitmap upload operations off of RenderThread.
Ensure EGL context outlives all upload requests

Bug: 79250950
Test: builds, boots, systrace is good, CTS bitmap tests pass

Change-Id: I5ace6c516d33b1afdf1a407cd8b183f6b60c22c1
2018-05-09 11:39:37 -07:00
John Reck
259b25a310 Switch RenderThread to a Java daemon thread
Bug: 69962494
Test: device boots, hwui unit tests pass
Change-Id: I9d5f2fccebf845328914c82aa97285cf605a4354
2017-12-01 16:35:06 -08:00
John Reck
1bcacfdcab Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-11-03 10:57:44 -07:00
John Reck
f8441e6552 Switch to a fancy new queue
Test: unit tests & benchmarks pass/faster

Change-Id: I9521432172d6dd6039c5280b1265479a36a86247
2017-10-27 13:39:55 -07:00
Chih-Hung Hsieh
49796451cb Fix clang-tidy warnings in libs/hwui.
* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1

Change-Id: Iab3e6636f60a70cb124f29dc19f20f842fa8dfda
2016-08-10 16:01:29 -07:00
Chih-Hung Hsieh
05160d70d1 resolve merge conflicts of 5152fd9 to stage-aosp-master
Change-Id: I2066125eb4076dbc9e8996bb1fa87735aa6040d3
2016-07-21 18:13:31 -07:00
Chih-Hung Hsieh
faecb78a6b Fix google-explicit-constructor warnings in frameworks/base
* Add explicit keyword to conversion constructors.
* Add NOLINT to implicit conversion constructors.

Bug: 28341362
Test: build with clang-tidy
Change-Id: Ie4d37072ab57d1662d18db4de1c8577247f43337
2016-07-21 16:24:06 -07:00
John Reck
ded1d3c45b Remove high-overhead low-signal trace section
Bug: 28519669

This trace tag makes shadows look way more expensive
than they actually are, particularly troublesome
when tracing things with large number of shadows.

Change-Id: Ib6558b1388edd4b006ec15127470cb9ab563f954
2016-05-02 16:24:28 -07:00
John Reck
38f6c034d1 Move updating window position off RT
Bug: 27385141
Change-Id: I6c75b5f1d9ef55ef64dde050f71d0e28fb8714bf
2016-03-17 10:32:07 -07:00
Chris Craik
b251a2f51e Revert "Revert "TaskManager bench""
This reverts commit 9640477e3cc075b0f303e817a3ebcc72d7bc878b.

Change-Id: I3aa8f2830b43b9c7b211c5792a311d0bc698c51a
2016-02-08 23:28:28 +00:00
Daniel Chapin
9640477e3c Revert "TaskManager bench"
This reverts commit 02db03ca0584371504fd29ced77c00d601cb0971.

Change-Id: I86bdf5e6774e99f9add59a657bfc50d45ebfda1d
2016-02-05 05:42:16 +00:00
Chris Craik
02db03ca05 TaskManager bench
bug:26964750

Change-Id: Ibda0cd2e5e64331a4367d4985d6acfd6f3baeda1
2016-02-04 14:42:43 -08:00
John Reck
272a685f17 Replace most usages of utils/Vector.h
Change-Id: I540d1b3523244d6c71fc52d6fb30555271c25644
2015-07-30 09:51:52 -07:00
John Reck
c452654a45 Restrict number of hwuiTask threads
Bug: 22324907
Change-Id: I0013557ede15949a5bd6f3f75bc5dd023a9f945b
2015-07-07 16:19:57 -07:00
Chris Craik
dee66b6d99 Simplify TaskManager fallback path
Change-Id: Ie3833449f7fe6aa69b9f71eb8bab1bef0fe434aa
2015-04-20 14:54:49 -07:00
John Reck
bf29ee2a49 Shave another 10us off of hwuitask
pthread_cond_signal does not need the mutex
to be held to signal. This results in the thread
waking up trying to grab the lock, failing, the signaling
thread to wake up, release the lock, immediately get preempted
for the signaled thread which can now proceed.

Release the mutex before signaling to avoid the ping-pong
scheduling issue, which shaves another 10us off of this

Change-Id: Ie6bccca031ba6528f357eae8352b74626a6318c7
2015-03-24 12:31:44 -07:00
John Reck
815f2a093a Shave 10us off of hwuitask
This prevents an issue where if the signal schedules
hwuiTask it will immediately block and go back to sleep due
to mLock still being held.

This costs 10us in thread scheduling ping-ponging bouncing
between hwuiTask and RenderThread

Change-Id: I47595c1bf5736576483a6aa7aada0b1be1e04268
2015-03-24 12:16:37 -07:00
John Reck
3f5175fccd resolved conflicts for merge of c7e6b93a to master
Change-Id: I4b791f37193727a0306214645f2f98cdf218cad0
2015-02-04 14:47:23 -08:00
John Reck
5ad36d4591 Merge "Fix ANR caused by hwuiTask thread" 2015-02-04 21:53:48 +00:00
Yabin Cui
026111bc56 am f7049289: am 3812e68e: Merge "kill HAVE_PTHREADS."
automerge: 3a10a67

* commit '3a10a672f05735be46256617b8a61cdb1e589008':
  kill HAVE_PTHREADS.
2015-01-27 23:27:37 +00:00
Yabin Cui
1610486d37 kill HAVE_PTHREADS.
Bug: 19083585
Change-Id: Ib466949bb6cd6d1bbc4680e989f0f9fae62ca564
2015-01-26 22:32:38 -08:00
Sangkyu Lee
c3c58e015f Fix ANR caused by hwuiTask thread
If hwuiTask thread is exited while HWUI renders something,
some tasks can remain unfinished forever.
This can make ANR problem if RenderThread waits this kind of tasks.

According to the current implementation, hwuiTask threads are
exited when HWUI receives trimMemory() callback with level >= 20
and some applications such as SystemUI can receive trimMemory()
with level >= 20 even though they renders something yet.
(For instance, when RecentsActivity in SystemUI is finished,
HWUI receives trimMemory() callback with level >= 20
but SystemUI should still render the status bar and navigation bar.)

This patch prevents the tasks from remaining unfinished and
make the tasks executed immediately if they cannot be added
to their TaskProcessors.

Change-Id: I5bd26439aa5f183b1a7c1ce466362e27554b4d16
2015-01-12 13:10:52 +09:00
Chris Craik
e84a208317 Add overrides and switch to nullptr keyword
Changes generated with clang-modernize.

Additionally, fixed some struct-vs-class usage to make clang happy.

Change-Id: Ic6ef2427401ff1e794d26f21f7b44868fc75fb72
2014-12-22 14:56:08 -08:00
John Reck
21be43e142 Fix hwuitask & RT priorities
Bug: 15993695

Change-Id: Ib6f07237cb834e8d10f3074f8fb206d27f91859a
2014-08-15 00:36:11 +00:00
Chris Craik
6ac174b972 Clean up tessellation cache in prep for other tesselation types
bug:15536396

Also fixes compilation warning, avoids SkPaint deep copy

Change-Id: I74334f08b1d34c6789aabf968ff62db5bacbed1b
2014-06-18 15:31:55 -07:00
Chris Craik
05f3d6e511 Tessellate on worker threads
Tessellate and cache (where possible) shadow and round rect
tessellation tasks.

Change-Id: I2cfda8e11d83d51ea74af871235cf26e8f831d40
2014-06-10 01:53:17 +00:00
Romain Guy
0a8c51b1d0 Properly account for created paths in the cache
Change-Id: I47b89b3085cefab6daac9194e7bfd3c140b37fa2
2013-08-21 17:35:38 -07:00
Romain Guy
78dd96d5af Add an on-screen overdraw counter
The counter can be enabled by setting the system property called
debug.hwui.overdraw to the string "count". If the string is set
to "show", overdraw will be highlighted on screen instead of
printing out a simple counter.

Change-Id: I9a9c970d54bffab43138bbb7682f6c04bc2c40bd
2013-05-03 17:08:20 -07:00
Romain Guy
c5cbee7d78 Stop worker threads on memory trim & fix bad pointer access
Change-Id: I6fe7e31aeb6dd41fa65ab952caed97bc2da510d7
2013-03-20 19:16:53 -07:00
Romain Guy
5dc7fa7096 Add TaskManager API
This API can be used to run arbitrary tasks on a pool of worker
threads. The number of threads is calculated based on the number
of CPU cores available.

The API is made of 3 classes:

TaskManager
      Creates and manages the worker threads.

Task
      Describes the work to be done and the type of the output.
      A task contains a future used to wait for the worker thread
      to be done computing the result of the task.

TaskProcessor
      The processor dispatches tasks to the TaskManager and is
      responsible for performing the computation required by
      each task. A processor will only be asked to process tasks
      sent to the manager through the processor.

A typical use case:

class MyTask: Task<MyType>

class MyProcessor: TaskProcessor<MyType>

TaskManager m = new TaskManager();
MyProcessor p = new MyProcessor(m);
MyTask t = new MyTask();
p.add(t);

// Waits until the result is available
MyType result = t->getResult();

Change-Id: I1fe845ba4c49bb0e1b0627ab147f9a861c8e0749
2013-03-12 15:06:42 -07:00
Romain Guy
ca89e2a687 Precache paths from a worker thread
Change-Id: I3e7b53d67e0e03e403beaf55c39350ead7f1e309
2013-03-11 17:05:28 -07:00