Repository: flutter
Issue: [Google maps plugin] Lag on IOS when using a large number of polylines. 
Labels: platform-ios,c: performance,p: maps,package,has reproducible steps,P2,found in release: 2.2,team-ios,triaged-ios

Loading a large number of polylines on IOS seems to run much slower than Android. For example see results of my testing below.   Notice that the Android lag increase roughly linearly (proportional to the number of polylines), while the IOS seems to increase exponentially. 

IOS
-Loading 3000 polylines: ~14 seconds
-Loading 4000 polylines:  ~22 seconds
-Loading 8000 polylines: ~87 seconds

Android
-Loading 3000 polylines: ~4 seconds
-Loading 4000 polylines: ~5 seconds
-Loading 8000 polylines: ~10 seocnds

I have observed equivalent performance disparities on both physical devices and emulators.   See sample app below that will recreate the issue as well as flutter doctor output. 





pubspec.yaml

google_maps_flutter: ^0.5.32





main.dart

```
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Map Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyStatelessWidget(),
    );
  }
}

class MyStatelessWidget extends StatelessWidget {
  MyStatelessWidget({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Map Test'),
        actions: <Widget>[],
      ),
      body: MapBody(),
    );
  }
}

class MapBody extends StatefulWidget {
  @override
  _MapBodyState createState() => _MapBodyState();
}

class _MapBodyState extends State<MapBody> {

  static  double centerLat = 40.7608;
  static double centerLong = -111.8910;
  
  MapType _mapType = MapType.normal;
   Set<Polyline> _polylines = {};
  CameraPosition _kInitialPosition =  CameraPosition(
    target: LatLng(centerLat, centerLong),
    zoom: 17.0,
  );

  @override
  Widget build(BuildContext context) {
 


    void _onMapCreated(GoogleMapController controller) {
      for (double i = 0; i < 4000; i++) {
        _polylines.add( Polyline(
                  polylineId: PolylineId(i.toString()),
                  width: 8,
                  points: [LatLng(centerLat+i*.0001, centerLong+i*.0001), LatLng(centerLat+i*2*.0001, centerLong+i*2*.0001)]
                ));
      }
      setState(() {});
    }

    return Stack(children: <Widget>[
      GoogleMap(
        myLocationEnabled: true,
        mapType: _mapType,
        polylines: _polylines,
        initialCameraPosition: _kInitialPosition,
        compassEnabled: false,
        onMapCreated: _onMapCreated,
      ),
   
    ]);
  }
}

```




```
[✓] Flutter (Channel master, 1.22.0-10.0.pre.121, on Mac OS X 10.15.6 19G2021, locale en-US)
    • Flutter version 1.22.0-10.0.pre.121 at /Users/rylandlueders/DevTools/flutter
    • Framework revision 6c1a29e54c (6 days ago), 2020-09-09 20:05:05 -0400
    • Engine revision 564367b297
    • Dart version 2.10.0 (build 2.10.0-107.0.dev)

 
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/rylandlueders/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.7, Build version 11E801a
    • CocoaPods version 1.9.3

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.49.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.14.1

[✓] Connected device (1 available)
    • iPhone 8 (mobile) • C4B2EE56-3935-471E-9E69-4DAC110DFC54 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-7 (simulator)

```