Repository: flutter
Issue: Android pointer position information is incorrect with Platform Views and Animations active
Labels: platform-android,engine,a: animation,f: gestures,a: platform-views,has reproducible steps,P1,found in release: 3.0,found in release: 3.1,team-android

While a platform view is on screen on Android, and also with an animation active, GestureDetector reports incorrect, jumpy values while dragging your finger (even if it's not moving).

This sample shows it in a log, however in real world apps, anything you are dragging (a ListView or anything) jumps wildly.

In the sample below, there is a commented out section for changing the webview to use non-hybrid mode for PlatformView. This, on flutter < 3.0.0 works around the issue, but probably due to #103630 has no effect on 3.0.0 and up.

This bug also happens < 3.0.0.

Digging down as far as we could in dart, we found that the values coming from window itself are incorrect, showing that data from the native side is broken.

## Steps to Reproduce

1. Make an app with the below code.
2. Add webview_flutter to pubspec.yaml
3. Run the app on an Android device
4. Initiate a drag and hold your finger there (don't move) and observe the TTT values rapidly jumping

**Expected results:** The TTT values should not be fluctuating.

**Actual results:** The TTT values fluctuate a lot, causing a 'jumping' behaviour.

<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  final GlobalKey _webviewKey = GlobalKey(debugLabel: 'WebView');
  late final AnimationController _controller;
  late final Animation<Offset> _animation;

  @override
  void initState() {
    super.initState();

    if (defaultTargetPlatform == TargetPlatform.android) {
      // Enable virtual display.
      // WebView.platform = AndroidWebView();
    }

    _controller = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 2000),
    )..repeat(reverse: true);

    _animation = Tween(
      begin: Offset.zero,
      end: const Offset(0.0, 0.5),
    ).animate(CurvedAnimation(
      parent: _controller,
      curve: Curves.linear,
    ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: GestureDetector(
        onVerticalDragDown: (details) {
          print('TTT:onVerticalDragDown:${details.localPosition.dy.toInt()}');
        },
        onVerticalDragUpdate: ((details) {
          print('TTT:${details.localPosition.dy.toInt()}');
        }),
        onVerticalDragEnd: (details) {
          print('TTT:onVerticalDragEnd');
        },
        child: SlideTransition(
          position: _animation,
          child: WebView(
            key: _webviewKey,
            initialUrl: 'https://flutter.dev',
          ),
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>
Not sure what the updateAcquireFence is.
Observe the TTT: values.

```
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +23 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +1 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[        ] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] I/flutter (18751): TTT:613
[        ] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] I/flutter (18751): TTT:561
[   +2 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +4 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] I/flutter (18751): TTT:559
[   +2 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +5 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[        ] I/flutter (18751): TTT:553
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] I/flutter (18751): TTT:557
[        ] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +13 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +4 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +11 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +5 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +5 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[  +10 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] I/flutter (18751): TTT:606
[   +2 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +6 ms] I/flutter (18751): TTT:554
[   +1 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +7 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +9 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
[   +8 ms] E/FrameEvents(18751): updateAcquireFence: Did not find frame.
```

```
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.2.1 21D62 darwin-arm, locale en-CA)
    • Flutter version 3.0.0 at XXXXXXX/flutter-3.0.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (4 weeks ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2
```

</details>