Skip to content

Infinite loop when using shape layers #2234

Description

@chehggg

What is the bug?

When implementing Flutter_web on Chrome and including polyline, polygon or circle layers with specified LatLng, it throws the below exception when the LatLng is scrolled into view:

Another exception was thrown: Assertion failed: "Infinite loop going beyond 30 for world width 2097152"

The map freezes and the shapes cannot be seen. The error is fired again whenever the map is hovered.

This issue does not exist in Windows app. I do not have other machine so I have not replicate it beyond using Chrome on my current machine. I have tried recreating multiple projects and run flutter clean and flutter pub get but they are result in same error.

How can we reproduce it?

main.dart

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget /dsadasd
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MapDrawingScreen(),
    );
  }
}

class MapDrawingScreen extends StatefulWidget {
  const MapDrawingScreen({super.key});

  @override
  State<MapDrawingScreen> createState() => _MapDrawingScreenState();
}

class _MapDrawingScreenState extends State<MapDrawingScreen> {
  MapController? _controller;

  @override
  void initState() {
    super.initState();
    _controller = MapController();
  }

  void onPresssed() {}
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Row(
          children: [
            Expanded(
              child: MapContainer(),
            ),
          ],
        ),
      ),
    );
  }
}

class MapContainer extends StatelessWidget {
  const MapContainer({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return FlutterMap(
      options: MapOptions(
        initialCenter: LatLng(15, 15),
      ),
      children: [
        TileLayer(
          urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
          userAgentPackageName: 'com.example.app',
        ),
        PolylineLayer(polylines: [Polyline(points: [LatLng(15, 15), LatLng(10, 12)])]),
        // CircleLayer(circles: [CircleMarker(point: LatLng(10, 10), radius: 5)])
      ],
    );
  }
}



When debugging in Chrome, the map throws the infinity loop error and freezes (because the polyline is in view).

Flutter doctor

[√] Flutter (Channel master, 3.47.0-1.0.pre-169, on Microsoft
    Windows [Version 10.0.26200.8875], locale en-US) [3.5s]
    • Flutter version 3.47.0-1.0.pre-169 on channel master aton
      D:\Document\flutter
    • Upstream repository` for more information.
      https://github.com/flutter/flutter.git
    • Framework revision 468c2c9d78 (8 hours ago), 2026-07-22
      07:51:27 +0000
    • Engine revision 468c2c9d78
    • Dart version 3.14.0 (build 3.14.0-46.0.dev)
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop,
      enable-macos-desktop, enable-windows-desktop,
      enable-android, enable-ios, cli-animations,
      enable-native-assets, enable-record-use,
      enable-swift-package-manager, omit-legacy-version-file,
      enable-lldb-debugging, enable-uiscene-migration,
      enable-riscv64

[√] Windows Version (11 Pro 64-bit, 25H2, 2009) [843ms]

[!] Android toolchain - develop for Android devices (Android
    SDK version 35.0.0) [293ms]
    • Android SDK at C:\Users\xz\AppData\Local\Android\sdk
    • Emulator version 32.1.13.0 (build_id 10086546) (CL:N/A)
    X cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from
      https://developer.android.com/studio#command-line-tools-o
      nly and make sure to set the ANDROID_HOME environment
      variable.
      See https://developer.android.com/studio/command-line for
      more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK
      licenses.
      See https://flutter.dev/to/windows-android-setup for more
      details.

[√] Chrome - develop for the web [78ms]
    • Chrome at C:\Program
      Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio
    Community 2019 16.11.1) [77ms]
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual
      Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31613.86
    • Windows 10 SDK version 10.0.19041.0

[√] Connected device (3 available) [230ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft
      Windows [Version 10.0.26200.8875]
    • Chrome (web)      • chrome  • web-javascript • Google
      Chrome 150.0.7871.129
    • Edge (web)        • edge    • web-javascript • Microsoft
      Edge 150.0.4078.83

[√] Network resources [1,341ms]
    • All expected network resources are available.

Do you have a potential solution?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis new bug report needs reproducing and prioritizing

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions