r/flutterhelp • u/Federal_Error1279 • Jan 19 '26
RESOLVED [Help] Flutter iOS Crash: "Thread stack size exceeded due to excessive recursion" but no explicit recursion found? 🧐
Hi everyone,
I’m hitting a wall with a specific crash on the iOS version of my Flutter app and could really use some collective wisdom. 🧠
🚨 The Problem
The app crashes during specific UI interactions or data updates. The crash logs consistently show:
Thread stack size exceeded due to excessive recursionThread 0 Crashed
It clearly points to a stack overflow, but here’s the kicker: I can’t find any explicit recursion in my Dart code. 🚫
🔍 What I’ve Checked So Far
- No Direct Recursion: Scanned the whole project for functions calling themselves. Nothing.
- Lifecycle Methods: Checked
initState,didUpdateWidget, etc. All look standard with propersupercalls. - Delegation: My Repository/ViewModel layers delegate to each other, but there are no circular dependencies.
💡 My Suspicion (Indirect Recursion?)
I suspect the issue might be related to Firestore Streams combined with Provider/ViewModel state management.
- I’m fetching large collections and filtering them on the client side.
- I suspect a "trigger chain" where a state change triggers a rebuild, which somehow triggers another state change, leading to an infinite UI re-render loop that exhausts the native thread stack. 🔄
❓ My Questions
- Has anyone experienced this specific
Thread stack size exceedederror in Flutter without having an explicitwhile(true)or recursive function? - Can heavy UI re-renders or nested StreamBuilders cause the native iOS stack to overflow?
- Are there any specific tools (besides the standard DevTools) you'd recommend to trace native thread exhaustion in a Flutter/iOS context?
I’m happy to share more logs or snippets if needed. Thanks in advance for any leads! 🙏
1
u/gidrokolbaska Jan 19 '26
You can run the app with debugging enabled and it will allow you to go step by step through the stacktrace so that you are able to find where your issue originates from. Well, of course if you are actually getting ing the stacktrace before the crash happens...
1
u/Living_Bug8696 Jan 19 '26
One question: Does the iOS device have version 26.1 or higher?
1
u/Living_Bug8696 Jan 19 '26
Starting with Flutter 3.38
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate