{"id":311211,"date":"2020-10-09T09:00:56","date_gmt":"2020-10-09T09:00:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=311211"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=311211","title":{"rendered":"\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/522670\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d07\/13f\/603\/d0713f603786397ce72b135e16cb7c12.jpg\" alt=\"image\"><\/p>\n<p>  \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u042a! \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/habr.com\/ru\/post\/521522\/\">\u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438-\u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f Activity \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440. \u041f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043b\u0435\u0434\u0443\u044f <a href=\"https:\/\/developer.android.com\/topic\/performance\/vitals\/launch-time#cold\" rel=\"nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Application.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430(MainThread aka UiThread).<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e Activity, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435.<\/li>\n<li>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435(\u0440\u0430\u0437\u0434\u0443\u0442\u0438\u0435, inflating) \u0432\u044c\u044e\u0448\u0435\u043a. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u044c\u044e\u0448\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 xml-\u0444\u0430\u0439\u043b\u0435.<\/li>\n<li>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432(View.measure()) \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f(View.layout()) \u0432\u044c\u044e\u0448\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/li>\n<\/ol>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u044b\u043b \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440, \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0444\u043e\u043d\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u043d\u0430 <b>Activity<\/b> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c78\/810\/caf\/c78810caf4c8d8ad88b0ae3bd245688e.png\" alt=\"image\"><\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0448\u0430\u0433\u0430\u0445.<\/p>\n<h2>\u0421\u0442\u0430\u0440\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430<\/h2>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438:<\/p>\n<ul>\n<li>\u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityThread.<b>main()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 IPC-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 ActivityManagerService.<b>attachApplication()<\/b> \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <b>system_server<\/b>.<\/li>\n<li><b>system_server<\/b> \u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0432\u044b\u0437\u043e\u0432 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 ActivityThread.<b>bindApplication()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0430\u0432\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <b>BIND_APPLICATION<\/b> \u0432 <b>MessageQueue<\/b> \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 IPC-\u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 ActivityManagerService.<b>attachApplication()<\/b> \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, ActivityThread.<b>main()<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Looper.<b>loop()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430(\u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442) \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u0432 <b>MessageQueue<\/b>.<\/li>\n<li>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u044d\u0442\u043e <b>BIND_APPLICATION<\/b>. \u0412 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 ActivityThread.<b>handleBindApplication()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 APK \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f89\/5db\/7f7\/f895db7f70e35d3c7c6a7eda0e34ba1e.png\" alt=\"image\"><\/p>\n<p>  <b>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/b> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f IPC-\u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 ActivityManagerService.<b>attachApplication()<\/b>.<\/p>\n<h2>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a Activity<\/h2>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 system_server \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 ActivityThread.<b>bindApplication()<\/b>:<\/p>\n<pre><code class=\"java\">public class ActivityManagerService extends IActivityManager.Stub {    private boolean attachApplicationLocked(       IApplicationThread thread, int pid, int callingUid,       long startSeq) {     thread.bindApplication(...);      \/\/ See if the top visible activity is waiting to run     \/\/  in this process...     mAtmInternal.attachApplication(...);      \/\/ Find any services that should be running in this process...     mServices.attachApplicationLocked(app, processName);      \/\/ Check if a next-broadcast receiver is in this process...     if (isPendingBroadcastProcessLocked(pid)) {         sendPendingBroadcastsLocked(app);     }     return true;   } }<\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0443 Activity \u2014 mAtmInternal.<b>attachApplication(&#8230;)<\/b>. \u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ActivityTaskManagerService.<b>attachApplication()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 RootActivityContainer.<b>attachApplication()<\/b>:<\/p>\n<pre><code class=\"java\">class RootActivityContainer extends ConfigurationContainer {    boolean attachApplication(WindowProcessController app) {     for (ActivityDisplay display : mActivityDisplays) {       ActivityStack stack = display.getFocusedStack()       ActivityRecord top = stack.topRunningActivityLocked();       stack.getAllRunningVisibleActivitiesLocked(mTmpActivityList);       for (ActivityRecord activity : mTmpActivityList) {         if (activity.app == null             &amp;&amp; app.mUid == activity.info.applicationInfo.uid             &amp;&amp; app.mName.equals(activity.processName)) {           mStackSupervisor.realStartActivityLocked(             activity,             app,             top == activity \/* andResume *\/,             true \/* checkConfig *\/           )         }       }     }     ...   } }<\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\u041e\u0431\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0438\u0441\u043f\u043b\u0435\u0439.<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0435\u043a \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 Activity \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0438\u0441\u043f\u043b\u0435\u044f.<\/li>\n<li>\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 Activity \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 Activity.<\/li>\n<li>\u0415\u0441\u043b\u0438 Activity \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 ActivityStackSupervisor.<b>realStartActivityLocked()<\/b>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>andResume<\/b> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 true \u0435\u0441\u043b\u0438 Activity \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u044d\u043a\u0430.<\/li>\n<\/ul>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityStackSupervisor.<b>realStartActivityLocked()<\/b>:<\/p>\n<pre><code class=\"java\">public class ActivityStackSupervisor{    boolean realStartActivityLocked(     ActivityRecord r,     WindowProcessController proc,     boolean andResume,     boolean checkConfig   ) {     ...     ClientTransaction clientTransaction = ClientTransaction.obtain(             proc.getThread(), r.appToken);      clientTransaction.addCallback(LaunchActivityItem.obtain(...));      \/\/ Set desired final state.     final ActivityLifecycleItem lifecycleItem;     if (andResume) {         boolean forward = dc.isNextTransitionForward()         lifecycleItem = ResumeActivityItem.obtain(forward);     } else {         lifecycleItem = PauseActivityItem.obtain();     }     clientTransaction.setLifecycleStateRequest(lifecycleItem);      \/\/ Schedule transaction.     mService.getLifecycleManager()       .scheduleTransaction(clientTransaction);     ...   } }<\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <b>system_server<\/b>. \u041c\u0435\u0442\u043e\u0434 ClientLifecycleManager.<b>scheduleTransaction()<\/b> \u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0432\u044b\u0437\u043e\u0432 ActivityThread.<b>scheduleTransaction()<\/b> \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ClientTransactionHandler.<b>scheduleTransaction()<\/b>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <b>EXECUTE_TRANSACTION<\/b>:<\/p>\n<pre><code class=\"java\">public abstract class ClientTransactionHandler {      \/** Prepare and schedule transaction for execution. *\/     void scheduleTransaction(ClientTransaction transaction) {         transaction.preExecute(this);         sendMessage(           ActivityThread.H.EXECUTE_TRANSACTION,           transaction         );     } }<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <b>EXECUTE_TRANSACTION<\/b> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 TransactionExecutor.<b>execute()<\/b>.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5a6\/35f\/3ad\/5a635f3ad1dee0056436609ae7744b07.png\" alt=\"image\"><\/p>\n<h2>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u043a Activity<\/h2>\n<p>  \u041c\u0435\u0442\u043e\u0434 TransactionExecutor.<b>execute()<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 TransactionExecutor.<br \/>  <b>performLifecycleSequence()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0432 ActivityThread \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f(<b>create<\/b>), \u0437\u0430\u043f\u0443\u0441\u043a\u0430(<b>start<\/b>) \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f(<b>resume<\/b>) Activity:<\/p>\n<pre><code class=\"java\">public class TransactionExecutor {    private void performLifecycleSequence(...) {     for (int i = 0, state; i &lt; path.size(); i++) {       state = path.get(i);       switch (state) {         case ON_CREATE:           mTransactionHandler.handleLaunchActivity(...);           break;         case ON_START:           mTransactionHandler.handleStartActivity(...);           break;         case ON_RESUME:           mTransactionHandler.handleResumeActivity(...);           break;         case ON_PAUSE:           mTransactionHandler.handlePauseActivity(...);           break;         case ON_STOP:           mTransactionHandler.handleStopActivity(...);           break;         case ON_DESTROY:           mTransactionHandler.handleDestroyActivity(...);           break;         case ON_RESTART:           mTransactionHandler.performRestartActivity(...);           break;       }     }   } }<\/code><\/pre>\n<p>  \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ea4\/40d\/6da\/ea440d6da021dcbb83ee81531c2fdb48.png\" alt=\"image\"><\/p>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440<\/h2>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0434\u0443\u0442 \u043a \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430:<\/p>\n<ul>\n<li>ActivityThread.<b>handleResumeActivity()<\/b><\/li>\n<li>WindowManagerImpl.<b>addView()<\/b><\/li>\n<li>WindowManagerGlobal.<b>addView()<\/b><\/li>\n<li>ViewRootImpl.<b>setView()<\/b><\/li>\n<li>ViewRootImpl.<b>requestLayout()<\/b><\/li>\n<li>ViewRootImpl.<b>scheduleTraversals()<\/b><\/li>\n<li>Choreographer.<b>postCallback()<\/b><\/li>\n<li>Choreographer.<b>scheduleFrameLocked()<\/b><\/li>\n<\/ul>\n<p>  \u041c\u0435\u0442\u043e\u0434 Choreographer.<b>scheduleFrameLocked()<\/b> \u0441\u0442\u0430\u0432\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <b>MSG_DO_FRAME<\/b>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/456\/2af\/c8c\/4562afc8c799e6e5f9fe907353d21619.png\" alt=\"image\"><\/p>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <b>MSG_DO_FRAME<\/b> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 Choreographer.<b>doFrame()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 ViewRootImpl.<b>doTraversal()<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u044b <b>measure pass<\/b> \u0438 <b>layout pass<\/b>, \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u043e\u0445\u043e\u0434 <b>the first draw pass<\/b> \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044c\u044e\u0448\u0435\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9cd\/466\/13f\/9cd46613f99f846d40eb88c6ccbb533c.png\" alt=\"image\"><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c78\/810\/caf\/c78810caf4c8d8ad88b0ae3bd245688e.png\" alt=\"image\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u00ab\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c\u00bb:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/780\/d8e\/566\/780d8e5664aa3628161ccb8777cc6594.png\" alt=\"image\"><\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u0441 \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0430\u043f\u0430\u0435\u0442 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b24\/ad9\/60d\/b24ad960d584aa6cacc6b3d9cb47f644.png\" alt=\"image\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c! \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/522670\/\"> https:\/\/habr.com\/ru\/post\/522670\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/522670\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d07\/13f\/603\/d0713f603786397ce72b135e16cb7c12.jpg\" alt=\"image\"><\/p>\n<p>  \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442\u042a! \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/habr.com\/ru\/post\/521522\/\">\u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438-\u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f Activity \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440. \u041f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-311211","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311211"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/311211\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}