Repository navigation
Revert: [flutter_tools] Fix Use dependency graph to determine plugin initialization order - #193686
flutteractionsbot wants to merge 1 commit into
Conversation
…initialization order (flutter#191591)" This reverts commit 086a6c8.
There was a problem hiding this comment.
Code Review
This pull request replaces dependency-based plugin sorting with alphabetical sorting by name across the Flutter tools and associated tests. The sortByDependencies function and its corresponding test cases have been removed to simplify the plugin ordering logic. I have no feedback to provide.
bkonyi
left a comment
There was a problem hiding this comment.
This isn't the cause of the analysis failures.
Confused because the dashboard claims this is the first PR to trigger failures: That's this PR: #191591 The SHA matches the dashboard SHA. The revert is this PR. The failure logs for that PR, as posted in its comments are:
Which both include: and That seems like the same failure. |

Reverts: [flutter_tools] Fix Use dependency graph to determine plugin initialization order
Initiated by: @cbracken
Reason for reverting: broke
Linux analyzer_benchmarkandLinux analyzeOriginal PR Author: @bkonyi
Reviewed By: @vashworth
The original PR description is provided below:
Fixes #99153
Summary
Flutter Issue Investigation: #99153
Issue: #99153 - Use dependency graph to determine plugin initialization order
Status: Resolved
Scope:
packages/flutter_tools1. Overview and Problem Statement
When Flutter generates native plugin registrants (such as
GeneratedPluginRegistrant.java,GeneratedPluginRegistrant.m,generated_plugin_registrant.cc,web_plugin_registrant.dart) and plugin dependency files (.flutter-plugins-dependencies), plugins were previously sorted purely alphabetically by plugin name (left.name.compareTo(right.name)).While alphabetical sorting ensured deterministic registrant generation, it did not take into account dependencies between plugins. If
plugin_adepended onplugin_z,plugin_awould be registered and initialized beforeplugin_z, leading to potential initialization order bugs when a plugin depends on services or state initialized by another plugin.2. Root Cause Analysis
findPlugins&refreshPluginsList:findPluginscollected plugins in arbitrary traversal order fromcomputeTransitiveDependencies.refreshPluginsListsortedpluginsalphabetically (plugins.sort((Plugin left, Plugin right) => left.name.compareTo(right.name));)._resolvePluginImplementationsByPlatform:pluginImplementations.sort((Plugin left, Plugin right) => left.name.compareTo(right.name));), overriding any topological order._writeFlutterPluginsListand Registrant Generators:3. Solution & Architecture
Topological Sort (
sortByDependencies)Implemented
sortByDependencies(Iterable<Plugin> plugins)inpackages/flutter_tools/lib/src/flutter_plugins.dart:plugin.dependencies. Non-plugin dependencies (e.g.,flutter,meta, external packages) are filtered out.Call Site Updates
findPluginsto returnsortByDependencies(plugins)._resolvePluginImplementationsByPlatformto sort platform implementations usingsortByDependencies(pluginResolution.values).plugins.sortinrefreshPluginsListandpackages/flutter_tools/lib/src/commands/build_swift_package.dart.4. Automated Testing and Verification
Regression & Unit Tests Added
Refreshing the plugin list sorts plugins by dependency orderinpackages/flutter_tools/test/general.shard/plugins_test.dart.group('sortByDependencies')inplugins_test.dart:returns empty list when input is emptyreturns single element list as-issorts independent plugins alphabeticallysorts direct dependency before dependent pluginsorts multi-level linear dependency chainsorts diamond dependency graphignores non-plugin dependencieshandles dependency cycle deterministically without throwing or hangingGenerated Linux plugin files sorts by dependency orderGenerated Windows plugin files sorts by dependency orderVerification Results
dart formatcleanly applied across all modified files.dart analyze --fatal-infos packages/flutter_tools: Passed with 0 errors, 0 warnings, 0 infos.dart test packages/flutter_tools/test/general.shard/plugins_test.dart: All 97 tests passing.Verification