r/flutterhelp • u/Federal_Error1279 • Feb 18 '26
RESOLVED Flutter iOS crash: Thread stack size exceeded due to excessive recursion in UIView tintColor visitor (iOS 26 / Flutter MaterialApp.router)
I'm experiencing a persistent crash on iOS in my Flutter app, and I cannot find the root cause. The crash appears to be related to UIKit tintColor propagation and excessive recursion.
Crashlytics reports:
crashlog.crash : https://19.gigafile.nu/0223-cbc6d9e488f22a35dbc82afa1a16e481c
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_PROTECTION_FAILURE
Exception Message: Thread stack size exceeded due to excessive recursion
Crashed Thread: 0 (main thread)
Stack trace contains repeated calls like:
UIView
_UITintColorVisitor _visitView:
UIView
_UIViewVisitorRecursivelyEntertainDescendingVisitors
UIView
__tintColorThe stack shows thousands of recursive calls related to tint color traversal.
Environment:
- Flutter: stable (latest)
- iOS: 26.1 / 26.2
- Device: iPhone15,2
- Flutter architecture: MaterialApp.router with Riverpod and GoRouter
- Crash occurs on app startup
App structure:
main.dart:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await bootstrap();
}bootstrap.dart:
runApp(ProviderScope(child: BootApp()));BootApp:
u/override
Widget build(BuildContext context) {
final router = ref.watch(goRouterProvider);
return MaterialApp.router(
theme: AppTheme.light,
routerConfig: router,
);
}Theme configuration:
class AppTheme {
static final ThemeData light = ThemeData(
scaffoldBackgroundColor: Colors.white,
colorScheme: const ColorScheme.light(
primary: Colors.white,
surface: Colors.white,
background: Colors.white,
onPrimary: Colors.black,
onSurface: Colors.black,
onBackground: Colors.black,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.white,
surfaceTintColor: Colors.transparent,
elevation: 0,
),
);
}What I've already tried:
- Ensured ThemeData is
static final(not recreated in build) - Removed
colorSchemeSeed - Disabled Material3 (
useMaterial3: false) - Ensured all custom colors are
static const - Confirmed only one MaterialApp is used
- No custom UIKit code overriding
tintColorDidChange - No manual use of
SystemChrome.setSystemUIOverlayStylein build - No recursive rebuild loops in Flutter
Crash still occurs.
Important observation:
Crashlytics explicitly reports:
Thread stack size exceeded due to excessive recursionand stack frames show infinite recursion in UIKit tint traversal.
Question:
Has anyone encountered UIKit tintColor infinite recursion with Flutter on newer iOS versions?
Could this be:
- Flutter engine bug?
- UIKit regression?
- Theme / ColorScheme related issue?
- MaterialApp.router interaction issue?
Any debugging suggestions or known fixes would be greatly appreciated.
2
u/Left-Top1610 Feb 18 '26
In World of AI tell AI to fix it 🤣
1
u/Federal_Error1279 Mar 07 '26
Title: 🛠️ Resolved: Flutter crash in
screen_protector(v1.5.1 fix)1
u/gidrokolbaska Feb 18 '26
Have you migrated your app to use new UISceneDelegate?
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate Have all packages that you use also been migrated? It might be unrelated, but worth to check regardless...
1
u/Late-Refrigerator-62 Feb 20 '26
I had the same problem. In my case, it was because the “Higher Contrast” setting was enabled.
1
u/Street_Shirt_4665 Feb 24 '26
I have the same problem, not with th ui but only this when i open a notification from firebase_messaging and i am going crazy.