Open philayres opened 9 years ago
Hi Phil,
Thanks for the thorough documentation of this issue. Let's get this fixed for the next release (1.5.9) and see if we can make it nice and swift. I suspect the issue is exactly as you suspect (repeated validation checks). I'll start profiling it to see if we can optimize the checks.
I'll use your data set from the fiddle to test against. Let's see how fast we can get it to render.
Hello,
i'm having the same issue with 1.5.9 and with firefox only (chrome and IE are OK), my json is totally similar to the one that philayres posted. I'm receiving too much recursion or stack overflow when the form loads and when i try to submit it, i receive the same error and i need to retry a couple more times to make it submit.
I belive that the validation system is not so well designed, expecially because you can have a very complex array structure and the full form analysis could be really expensive in terms of memory and time. Now, this problem may happen in firefox only, but i think that he has the rights to strike that error, because it's a fact that the recursion could be REALLY big.
@philayres ran this through a test on the latest build from head and no stack errors. So at least we've solved that problem. To the point that @Reikun85 makes, I agree. The validation logic is really soaking up most of the time. The design may need to be revisited and optimized a bit. I'm seeing rendering times now of 4-5 seconds on head which is an improvement. But still not truly resolved.
I've started pushing the limits again, it seems. I have a form that has two levels of array types, basically representing the equivalent of a two level folder structure. Even this example with less than 40 items total takes about 8 seconds to display on my desktop machine, and significantly worse on a tablet.
On Firefox a strange recursion error is reported in the console (inside Jquery, though I think that's just because it randomly hits there), but the form still loads.
Just help put it in perspective, the data is really not that complex, with 10 items at the first level, 24 total at the second level, where a first level 'container' has at most 8 second level items. Each second level item object has at most 10 fields.
Try this jsfiddle to see what I mean: https://jsfiddle.net/phil_ayres/hcqn4fww/1/ I have removed any custom fields and styling, so it looks like a bunch of horribleness, but it should load, eventually.
The fiddle is using v1.5.8 which is loading from the file on your tutorials page. I have also been using a modified version of 1.1.2 (since I've never got to the point of revalidating my changes against your new version). Neither version seems significantly faster than the other.
I attempted to profile the page, and I can see that Alpaca.compileValidationContext is a major time suck, but I haven't really worked out what's going on in there to make it so bad. I fear that is a red herring, since the same is not true in the 1.1.2 version (I know they are significantly different in the way they operate, so no surprises).
I don't feel that this is an excessive amount of data to cause such a delay, so I'm not convinced that the complexity of my data should be the issue, since I have other forms (consisting exclusively of nested objects, rather than arrays) that have more fields in total and load faster.
I feel like there is a potential issue where every field leads to every other field being checked as it is added (for dependencies or validity, or something), but that's a guess at this point. I'm open to suggestions where to look.