Repository: flutter
Issue: [google_maps_flutter] Android TalkBack crashes when useAndroidViewSurface is false
Labels: c: crash,e: device-specific,platform-android,a: accessibility,p: maps,customer: google,package,P2,customer: castaway,team-android,triaged-android

Internal: b/329766984

### Steps to reproduce

1. Enable Android TalkBack (Settings -> Accessibility -> TalkBack).
2. Open a Flutter app using google_maps_flutter and a useAndroidViewSurface value of false (the current default).
3. Interact with the map.
4. Observe crashes of the TalkBack service, effectively ANR'ing the app itself.

### Expected results

TalkBack should not crash when used in an app using google_maps_flutter.

### Actual results

TalkBack crashes and causes the app to be unusable.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

void main() async {
  //*****ENABLE this line to avoid TalkBack crashing
  // _googleMapsFlutterSetup();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: GoogleMapPage(),
    );
  }
}

void _googleMapsFlutterSetup() {
  final mapsImplementation = GoogleMapsFlutterPlatform.instance;
  if (mapsImplementation is GoogleMapsFlutterAndroid) {
    mapsImplementation.useAndroidViewSurface = true;
  }
}

class GoogleMapPage extends StatefulWidget {
  GoogleMapPage({Key? key}) : super(key: key);

  @override
  State<GoogleMapPage> createState() => _GoogleMapPageState();
}

class _GoogleMapPageState extends State<GoogleMapPage> {
  @override
  Widget build(BuildContext context) {
    return GoogleMap(
      initialCameraPosition:
          const CameraPosition(target: LatLng(0.0, 0.0), zoom: 1),
    );
  }
}
```

</details>


### Screenshots or Video

_No response_

### Logs

<details open><summary>Logs</summary>

```console
E/AndroidRuntime(11211): FATAL EXCEPTION: main
E/AndroidRuntime(11211): Process: com.google.android.marvin.talkback, PID: 11211
E/AndroidRuntime(11211): java.lang.StackOverflowError: stack size 8188KB
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityNodeInfo.init(AccessibilityNodeInfo.java:4157)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityNodeInfo.<init>(AccessibilityNodeInfo.java:944)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityCache.getNode(AccessibilityCache.java:344)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityInteractionClient.findAccessibilityNodeInfoByAccessibilityId(AccessibilityInteractionClient.java:541)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityNodeInfo.getNodeForAccessibilityId(AccessibilityNodeInfo.java:4625)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityNodeInfo.getNodeForAccessibilityId(AccessibilityNodeInfo.java:4614)
E/AndroidRuntime(11211): 	at android.view.accessibility.AccessibilityNodeInfo.getParent(AccessibilityNodeInfo.java:1903)
E/AndroidRuntime(11211): 	at androidx.core.view.accessibility.AccessibilityNodeInfoCompat.getParent(PG:1)
E/AndroidRuntime(11211): 	at com.google.android.accessibility.utils.ScrollableNodeInfo.findScrollableNodeForDirectionRecursive(PG:2)
E/AndroidRuntime(11211): 	at com.google.android.accessibility.utils.ScrollableNodeInfo.findScrollableNodeForDirectionRecursive(PG:2)
E/AndroidRuntime(11211): 	at com.google.android.accessibility.utils.ScrollableNodeInfo.findScrollableNodeForDirectionRecursive(PG:2)
E/AndroidRuntime(11211): 	at com.google.android.accessibility.utils.ScrollableNodeInfo.findScrollableNodeForDirectionRecursive(PG:2)
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel google3, on macOS 14.4 23E214 darwin-x64, locale en)
    • Framework revision 03b5ea519a (2 days ago), 2024-03-18T00:00:00.000
    • Engine revision aebc0021cd
    • Dart version d5cf2d3849

[✓] Android toolchain - develop for Android devices (Android SDK version Stable)
    • Android SDK at google3
    • Platform Stable, build-tools Stable
    • Java binary at: /Applications/Android Studio with Blaze
      Beta.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.9+0-17.0.9b1087.7-11185874)

[✓] GoogleMac (on macos)
    • AppleWWDRCA installed.
    • Google development certificate installed.
    • Device 00008101-000539403403001E is whitelisted

[✓] Connected device (2 available)
    • Pixel 4 (mobile) • 99211FFAZ0054E • android-arm64 • Android 13 (API 33)

• No issues found!
```

</details>