Repository: flutter
Issue: When using platformView, how can I obtain FrameTiming?
Labels: engine,a: platform-views,P2,team-engine,triaged-engine

When I use platformView, scrolling the page does not trigger the callback:
SchedulerBinding.instance.addTimingsCallback((List<FrameTiming> timings) { print("test $timings}"); });

this is my code:

flutter code:
main.dart
```
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:fluttertest/native_view.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  void initState() {
    super.initState();
    SchedulerBinding.instance.addTimingsCallback((List<FrameTiming> timings) {
      // not work when scrolling the page
      print("test $timings}");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center (
        child: Container(
          height: double.infinity,
          width: double.infinity,
          child: NativeWebView(),
        ),
      )// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
```
native_view.dart
```
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class NativeWebView extends StatelessWidget {

  const NativeWebView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // This is used in the platform side to register the view.
    const String viewType = '<platform-view-type>';
    // Pass parameters to the platform side.
    final Map<String, String> creationParams = <String, String>{
      "url": "https://www.baidu.com"
    };

    return AndroidView(
      viewType: viewType,
      layoutDirection: TextDirection.ltr,
      creationParams: creationParams,
      creationParamsCodec: const StandardMessageCodec(),
    );
  }
} 
```

android code:
MainActivity.kt
```
 import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine

class MainActivity : FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        flutterEngine
            .platformViewsController
            .registry
            .registerViewFactory("<platform-view-type>", NativeViewFactory())
    }
}
```
NativeView.kt
```
 import android.annotation.TargetApi
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.view.View
import android.webkit.WebView
import android.widget.TextView
import io.flutter.plugin.platform.PlatformView

@TargetApi(Build.VERSION_CODES.CUPCAKE)
internal class NativeView(context: Context, id: Int, creationParams: Map<String?, Any?>?) : PlatformView {
    private val webView: WebView

    override fun getView(): View {
        return webView
    }

    override fun dispose() {}

    init {
        webView = WebView(context)

        webView.apply {
            settings.apply {
                // enable Javascript
                javaScriptEnabled = true
                setSupportZoom(true)
                builtInZoomControls = true
            }
        }

        if (creationParams != null) {
            val url = creationParams["url"]
            if (url is String) {
                webView.loadUrl(url)
            }
        } else {
            webView.loadUrl("https://www.baidu.com");
        }
    }
}
```
NativeViewFactory.kt
```
 import android.content.Context
import android.view.View
import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory

class NativeViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
    override fun create(context: Context, viewId: Int, args: Any?): PlatformView {
        val creationParams = args as Map<String?, Any?>?
        return NativeView(context, viewId, creationParams)
    }
}
```
I scroll this page, but the callback  is not executed.
<img width="555" alt="image" src="https://github.com/flutter/flutter/assets/48858746/b9bd10d1-6ddf-461f-b58e-7cf2bae5b356">