Skip to content

[google_maps_flutter_web] Don't hang onMapCreated when tiles fail to load - #13059

Open
mdebbar wants to merge 11 commits into
flutter:mainfrom
mdebbar:gmaps-web-onmapcreated-hang
Open

mdebbar wants to merge 11 commits into
flutter:mainfrom
mdebbar:gmaps-web-onmapcreated-hang

Conversation

@mdebbar

@mdebbar mdebbar commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The web plugin reported a map as ready (triggering onMapCreated) only on the first tilesloaded event. That event requires every visible tile to download, so a single stalled or failed tile request leaves onMapCreated pending forever. On CI, this hangs projection_test, overlays_test, and marker_clustering_test until flutter drive fails with an opaque DriverError after 20 minutes.

Example CI failures:

Fixes flutter/flutter#193452

…load

The map was only reported as ready on the first 'tilesloaded' event,
which never fires if a tile request stalls or fails. Also accept the
first 'idle' event once the map div is laid out.

Integration tests now time out waiting for the map instead of hanging
until the driver fails with an opaque DriverError.

Fixes flutter/flutter#193452
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the web implementation of the Google Maps Flutter plugin to ensure that onMapCreated is called even if a map tile fails to load. It updates _attachMapEvents in GoogleMapController to trigger the map-ready event using either the first tilesloaded event or the first idle event after the map's div is connected and has a positive width. Additionally, integration tests are updated to use a new helper function, waitForMap, which adds a 30-second timeout to map-creation futures to prevent test hangs. Feedback suggests also checking offsetHeight in addition to offsetWidth to guarantee the map is fully laid out and usable.

@mdebbar mdebbar changed the title [google_maps_flutter_web] Don't hang onMapCreated when tiles fail to load [google_maps_flutter_web] Don't hang onMapCreated when tiles fail to load Oct 1, 2026
@mdebbar

mdebbar commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

To check whether this actually removes the hang rather than just making it rarer, I ran the web_platform_tests_shard_1 builders (master, stable, wasm) repeatedly against this change with per-map telemetry (5c7cda17a7, 3fde69183a) and a 6× cold-start multiplier (255a224786, each build runs flutter drive 6 times for projection_test, overlays_test, and marker_clustering_test). The instrumentation is not in the final PR.

Results: 59 builds, 309 cold-start build-equivalents, 2,880 instrumented GoogleMap instances, 0 failures. The historical rate for this hang is ~2.2% per build, so the chance of seeing 0 failures by luck is ~0.1%. On every one of the 2,880 maps, idle fired with a laid-out div before tilesloaded (p50 82 ms vs 497 ms), and a detached 0×0 div never emitted idle.

Caveat: the historical failures cluster by date (3 on 2026-09-25), so the builds are not fully independent and this is an upper bound on confidence. I also never caught a stalled tilesloaded red-handed during the campaign; if the hang recurs, the new timeout message in pumpMap will say whether the map div was attached, which is what separates a tile stall from a Maps JS load failure.

All builds: bb ls -t buildset:sha/git/255a22478659f39967646cc2ad87a5420e074096 flutter/try (plus the three earlier SHAs below).

All 59 shard_1 builds
# Commit Mode Builder Status Build
1 913c34e41b 1× (diagnostics only) Linux_web web_platform_tests_shard_1 master SUCCESS 8669293456277941521
2 913c34e41b 1× (diagnostics only) Linux_web web_platform_tests_shard_1 stable SUCCESS 8669293456318974689
3 913c34e41b 1× (diagnostics only) Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669293456318974737
4 5c7cda17a7 1× (telemetry) Linux_web web_platform_tests_shard_1 master SUCCESS 8669211218053478497
5 5c7cda17a7 1× (telemetry) Linux_web web_platform_tests_shard_1 stable SUCCESS 8669211217956055505
6 5c7cda17a7 1× (telemetry) Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669211217956055553
7 3fde69183a 1× (telemetry) Linux_web web_platform_tests_shard_1 master SUCCESS 8669210068236519457
8 3fde69183a 1× (telemetry) Linux_web web_platform_tests_shard_1 stable SUCCESS 8669210068096309425
9 3fde69183a 1× (telemetry) Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669210068096309473
10 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205466460641233
11 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205466601076129
12 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205466601076177
13 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840465
14 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840481
15 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840497
16 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840513
17 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840529
18 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840545
19 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669205416137840561
20 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840577
21 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840593
22 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840609
23 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840625
24 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840641
25 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840657
26 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205416137840673
27 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840353
28 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840369
29 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840385
30 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840401
31 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840417
32 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840433
33 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205416137840449
34 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669205357721714801
35 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669205357721714785
36 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566129
37 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566145
38 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566161
39 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566177
40 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566193
41 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566209
42 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566225
43 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 master SUCCESS 8669204482921566241
44 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566257
45 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566273
46 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566289
47 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566305
48 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566321
49 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566337
50 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566353
51 255a224786 6× cold-start Linux_web web_platform_tests_shard_1 stable SUCCESS 8669204482921566369
52 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566001
53 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566017
54 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566033
55 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566049
56 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566065
57 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566081
58 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566097
59 255a224786 6× cold-start Linux_web web_platform_tests_wasm_shard_1 master SUCCESS 8669204482921566113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_maps_flutter_web] projection_test.dart flakily fails with DriverError on web

1 participant