Repository navigation
Description
Steps to reproduce
Create a large Flutter Web ERP project.
Use approximately 800 feature controllers.
Each feature controller inherits from a common generic Bloc hierarchy.
Each controller mixes in 20+ generic mixins through a shared contract class.
Run:
flutter clean
flutter pub get
flutter run -d chrome
Observe compilation time and application startup behavior.
Expected results
Flutter Web should compile and start the application within a reasonable time.
Expected:
Web compilation time remains stable as the project scales.
Application reaches main() quickly after Chrome launches.
Application successfully loads the first screen.
No startup timeout occurs.
Actual results
After migrating from a composition-based architecture to a generic Bloc + Mixin architecture:
Compilation
Composition Architecture:
3–4 minutes
Bloc + Generic Mixins Architecture:
8–10 minutes
Application Startup
After Chrome launches:
Application initialization is significantly slower.
main() takes a long time to complete.
Initial dependency injection and controller registration become extremely slow.
Application frequently exceeds startup timeout limits.
Browser eventually disconnects and the application closes before the first screen is rendered.
This behavior did not occur before the architectural change.
Code sample
Code Sample
The issue appears when a large number of feature controllers inherit from the same generic Bloc hierarchy and mixin chain.
Base State
abstract class FeatureState {}
class InitialFeatureState extends FeatureState {}Base Bloc
import 'package:flutter_bloc/flutter_bloc.dart';
abstract class FeatureBlocBase<T extends FeatureState>
extends Bloc<Object, T> {
FeatureBlocBase(T initialState) : super(initialState);
}Interfaces
abstract class IDeleteMixin {
Future<void> delete();
}
abstract class ISearchMixin {
Future<void> search();
}
abstract class IPrintMixin {
Future<void> printDocument();
}
abstract class IUpdateMixin {
Future<void> update();
}Main Contract
abstract class IFeatureBloc
implements
IDeleteMixin,
ISearchMixin,
IPrintMixin,
IUpdateMixin {}Generic Mixins
mixin DeleteMixin<T extends FeatureState>
on FeatureBlocBase<T>
implements IDeleteMixin {
@override
Future<void> delete() async {
// register events
}
}mixin SearchMixin<T extends FeatureState>
on FeatureBlocBase<T>
implements ISearchMixin {
@override
Future<void> search() async {
// register events
}
}mixin PrintMixin<T extends FeatureState>
on FeatureBlocBase<T>
implements IPrintMixin {
@override
Future<void> printDocument() async {}
}mixin UpdateMixin<T extends FeatureState>
on FeatureBlocBase<T>
implements IUpdateMixin {
@override
Future<void> update() async {}
}Common Feature Bloc
abstract class FeatureBloc<T extends FeatureState>
extends FeatureBlocBase<T>
with
DeleteMixin<T>,
SearchMixin<T>,
PrintMixin<T>,
UpdateMixin<T>
implements IFeatureBloc {
FeatureBloc(super.initialState);
}Real Feature
class CustomerState extends FeatureState {}
class CustomerBloc extends FeatureBloc<CustomerState> {
CustomerBloc() : super(CustomerState());
}Scale In Production
The actual project contains:
- ~800 feature controllers
- ~20+ generic mixins
- ~20+ interface contracts
- 15 business modules
- Shared core package
Every feature controller inherits the same hierarchy:
CustomerBloc
↓
FeatureBloc<T>
↓
FeatureBlocBase<T>
↓
Bloc<Event, State>
+ 20 Generic Mixins
+ 20 Interface Contracts
Observed Results
Composition Architecture:
flutter run -d chrome
3-4 minutes
Generic Bloc + Mixins Architecture:
flutter run -d chrome
8-10 minutes
Additional symptom:
After Chrome launches, application bootstrap becomes very slow and frequently exceeds startup timeout before rendering the first screen.
Screenshots or Video
Logs
PS C:\Users\PR> Flutter --verbose create foo
[ +726 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ +1 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +1 ms] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +1 ms] executing: [C:\src\PR\Flutter/] git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
[ +82 ms] Exit code 0 from: git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
[ ] 2026-07-17 10:20:17 -0700
[ +13 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +51 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +60 ms] Unable to get code-sign settings on non-Mac platform.
[ +11 ms] Creating project foo...
[ +773 ms] executing: [C:\Users\PR/] C:\src\PR\Flutter\bin\cache\dart-sdk\bin\dart pub --suppress-analytics --color --directory foo get --example
Resolving dependencies in foo...
Downloading packages...
Got dependencies in foo.
[ +616 ms] Generating C:\Users\PR\foo\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[ +120 ms] Wrote 131 files.
[ ]
All done!
[ +4 ms] You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd foo
$ flutter run
Your application code is in foo\lib\main.dart.
[ +14 ms] executing: C:\Program Files\Android\Android Studio1\jbr\bin\java -version
[ +207 ms] Exit code 0 from: C:\Program Files\Android\Android Studio1\jbr\bin\java -version
[ ] openjdk version "21.0.10" 2026-01-20
OpenJDK Runtime Environment (build 21.0.10+-14961533-b1163.108)
OpenJDK 64-Bit Server VM (build 21.0.10+-14961533-b1163.108, mixed mode)
[ +3 ms] executing: C:\Program Files\Android\Android Studio1\jbr\bin\java --version
[ +192 ms] Exit code 0 from: C:\Program Files\Android\Android Studio1\jbr\bin\java --version
[ ] openjdk 21.0.10 2026-01-20
OpenJDK Runtime Environment (build 21.0.10+-14961533-b1163.108)
OpenJDK 64-Bit Server VM (build 21.0.10+-14961533-b1163.108, mixed mode)
[ +4 ms] "flutter create" took 2,089ms.
[ +90 ms] Running 1 shutdown hook
[ +2 ms] Shutdown hooks complete
[ +170 ms] exiting with code 0
PS C:\Users\PR>
Flutter Doctor output
Changed 7 dependencies!
2 packages have newer versions incompatible with dependency constraints.
Try flutter pub outdated for more information.
🔒 Lock released.
Done with C:\Users\PR\package\onyx_ix_debug_assets
ALL projects processed.
PS C:\Users\PR> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[v] Flutter (Channel stable, 3.44.7, on Microsoft Windows [Version 10.0.20348.5256], locale en-US)
[v] Windows Version (Server 2022 Standard 64-bit)
[v] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[v] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.9 (July 2025))
! Unable to locate a Windows 10 SDK. If building fails, install the Windows 10 SDK in Visual Studio.
[v] Connected device (2 available)
[v] Network resources
! Doctor found issues in 1 category.
PS C:\Users\PR>
Activity
mbcorona commentedon Aug 3, 2026
Thanks for the report.
To investigate this we need a minimal reproducing project we can build ourselves, since the slowdown depends on the scale you describe. Could you share:
A minimal repo that reproduces the compile-time increase (even a generated one with many controllers/mixins).
Build timing with flutter build web --verbose (or a compiler trace) for the slow case.
It would also help to separate the two symptoms: the compile-time cost (likely in the Dart web compiler) versus the runtime startup slowness after main() (which may be your DI/registration).
Once we have a repro we can route this to the right team.
MohamedRashad99 commentedon Aug 18, 2026
@mbcorona Thank you for your response and for the detailed guidance.
We have prepared a minimal reproducing repository that demonstrates the issue for your review. Please have a look, and we’ll be happy to provide any additional information or build traces needed to help with the investigation.
https://github.com/MohamedRashad99/erp_sim_example
mbcorona commentedon Aug 19, 2026
Hi @MohamedRashad99, thanks for the reproduction. The control variant rules out code size, and it only slows down on DDC (not dart2js), so this points at the DDC compiler. Routing to the web team.
14 remaining items
[ddc] Cache the library identifier used in interface type recipes
mdebbar commentedon Sep 23, 2026
Another report that looks similar to this: #192687
Markzipan commentedon Sep 28, 2026
@MohamedRashad99 I landed an update that shaves ~30% of the startup time off - though I'm still looking into other ways to fix the slowdowns (runtime in particular). It's not yet in the latest Flutter release though.
rahmaeid182 commentedon Sep 30, 2026
I am also running into this exact same architectural bottleneck in a heavily modularized Flutter Web application.
To add another perspective on how this impacts the development cycle: the issue isn't just the raw 8–10 minute compilation time, but the immense memory pressure and browser unresponsiveness it creates on the client side. Because our architecture relies on a similar pattern (base controllers funneling through multiple generic mixins), the DDC output results in a massive JavaScript payload inflated by those deep synthetic prototype chains.
When Chrome tries to parse, compile, and instantiate this hierarchy during a hot restart or initial boot, the browser tab frequently locks up, drops frames, or outright crashes before Dart's main() even has a chance to execute. It behaves as though the V8 engine is choking on the sheer volume of virtual classes, generic type reifications, and synthetic getters/setters that DDC is forced to generate to maintain Dart's type semantics.
@mbcorona @Markzipan @mraleph @mdebbar
@Markzipan — Thanks for the transparent breakdown regarding how DDC handles mixin representations compared to dart2js. It is great to hear about the recent update shaving ~30% off the startup time! The strategy of collapsing "simple" mixins into the class's prototype sounds exactly like what heavily abstracted projects need to become viable on DDC again. We are eagerly looking forward to testing the remaining runtime improvements once they land.
[ddc] Cache intermediate products of _collectNativeMembers
Hussein2077 commentedon Oct 11, 2026
Markzipan commentedon Oct 14, 2026
Responding on behalf of @nshahan, you should be able to try this in our upcoming beta branch: #194269
The most recent of the changes is this: dart-lang/sdk@b90ab5f
Which unfortunately didn't make it into October 1st's beta.
ALI-tech-tech commentedon Oct 25, 2026
ALI-tech-tech commentedon Oct 25, 2026
Markzipan commentedon Oct 26, 2026
@ALI-tech-tech Was the performance in beta resolved?
The next Flutter stable release will be some time in November, but I'm not sure about the exact date (I suspect it'll be the first half). It will have these fixes though. I'll see if we can do a cherry-pick.
MinaFaried3 commentedon Oct 27, 2026
@Markzipan Thanks for the update!
Could you please let me know which Flutter beta version or specific build I should test to verify the performance improvements?
Also, if there are any additional scenarios, benchmarks, or specific areas you’d like me to investigate, I’d be happy to run further tests and share detailed performance results and feedback to help validate the fixes before the stable release.
Markzipan commentedon Oct 27, 2026
Try the most recent beta:
3.50.0-0.2.preSo:
Should do it.
ALI-tech-tech commentedon Oct 28, 2026
I've tested the latest version, and it shows a good improvement. However, I'm still encountering an issue a few moments after starting the app in Chrome debug mode.
The connection to the web debug service fails with a
TimeoutExceptionafter 5 seconds, as shown in the screenshot.Has anyone else encountered this issue with the latest version?
@Markzipan
Markzipan commentedon Oct 29, 2026
This is the same issue here, and I'll have a fix out soon: dart-lang/webdev#2883
Unfortunately this will require a dwds bump in flutter_tools (and potentially a cherrypick). I'll get the fix landed and see if we can fix this up asap for you all.
Markzipan commentedon Nov 4, 2026
Quick update: can you check out
flutter channel masterafter this PR lands? #195932It should have the timeout bug fixes. If that works, I can try to get a cherrypick into beta/stable sooner.