(两百六十二)结合perfetto观察flutter 和 Android 的加载过程

1.两个demo

最简单最初始的demo肯定是hello world啦

flutter

import 'package:flutter/material.dart';

void main() {
  runApp(
    Center(
      child: Text(
        'Hello, world!',
        textDirection: TextDirection.ltr,
      ),
    ),
  );
}

android

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"/>

</LinearLayout>


package com.example.hello_world;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

 

2.抓取trace

2.1 flutter

主线程:PostFork+ZygoteInit+ActivityThreadMain+setCoreSettings+bindApplication(makeApplication)+activityStart(inflate)+activityResume+Choreographer#doFrame(measure+layout+draw)

RenderThread:

setSurface+DrawFrame(dequeueBuffer+flush commands+eglSwapBuffersWithDamageKHR+queueBuffer+frameComplete 1)

 

2.2 android

主线程:PostFork+ZygoteInit+ActivityThreadMain+setCoreSettings+bindApplication(makeApplication)+activityStart(inflate)+activityResume+Choreographer#doFrame(measure+layout+draw)

RenderThread:

setSurface+DrawFrame(dequeueBuffer+flush commands+eglSwapBuffersWithDamageKHR+queueBuffer+frameComplete 1)

 

3.总结

仔细对照了下Android版本的helloworld和flutter版本的hello world从perfetto来看大体流程并没什么区别,flutter可以认为是定制化的Android应用,与Android交互的流程逻辑还是走的Android现有的那套,至少从perfetto trace的视角来看是这样。

 

相关推荐
©️2020 CSDN 皮肤主题: 鲸 设计师:meimeiellie 返回首页