Relevant Qt version: 5.15 I've recently been investigating a weird "Range error: maximum call stack size exceeded" in our application and I think I've tracked down what's happening, but I don't know if there are ways of dealing with that.
In essence: when a form has a large amount of subforms and Components, then, in the internals of qml engine, it is parsed and every piece of it is assigned totalObjectCount which is accumulated recursively for big forms. Then, in qjsengine sources this happens: sharedState->allJavaScriptObjects = scope.alloc(compilationUnit->totalObjectCount()); As far as I understand, this doesn't even allocate anything, just bumps jsStackTop pointer to a new value. The problem with it is that once the application tries to initialize a component from c++ (say, we have triggered a c++ side attached property and it, in its constructor, tries component instantiation) we end up calling engine->jsStackTop += frame.requiredJSStackFrameSize(); and once we do `checkStackLimits` qt suddenly realizes that we're (already) past the default javascript stack and issue a RangeError. Funny thing is that no range checking is seemingly happening when the form itself is parsed and only when we try to add a new component from c++ the engine suddenly realizes that our jsStackTop is already a fair bit past the jsStackLimit. The form that triggers this has a lot of components attached to it and not all of them are instantiated at the same time, but qt seemingly bumps jsStackTop to a value that accumulates all of their objectCounts which ends up in the range of ~1 million. Is there some kind of pattern that will let javascript engine handle it more gracefully and not try to reserve stack for everything at once? Is it possibly correct to just bump the JS stack size via environment variable and forget about it?
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest