Closed neuronix closed 7 years ago
Thanks a lot for the heads-up, and for posting a possible workaround!
I contacted Adobe again about this issue (there's also a report on Adobe Tracker, and they said they are working on it. But we probably can't wait for the results ... who knows when the fix is going to be released.
I'm curious — did you also try to replace the Vector with an Array? I've run into performance problems with the Vector in AOT mode several times in the past, and often the standard Array worked better.
I didn't think of trying an Array, I don't have much time for optimization right now, I just wanted to fix this as it was a big issue.
I'll investigate that later, our app is probably a good benchmark for testing since we use DistanceFieldStyle extensively so BatchPool is having to work pretty hard! I'll let you know what I find :)
Don't worry, do it only when time allows it. I'll probably give it a try myself, too. Thanks again for sharing your solution, in any case, and all the best for your upcoming project!
Semi-good news: while this still isn't fixed on Adobe's side, at least there is an easier workaround: using an Array instead of a Vector. That's not the first issue caused by Vectors in AOT compilation ... seems to be tricky with this mode.
Okay, thanks for the info. However I still think that you should make and exception for MeshStyle & DistanceFieldStyle because of how many times per frame they will be used. I know my suggestion isn't aesthetically appealing but it does avoid a "useless" Dictionary call :)
Well, it's only one Dictionary access per draw call, so it's probably not super critical — but I'll think about it!
Hi Daniel,
On ios our app had 45% of cpu time used up by BatchPool.get & memory cleaning due to a very high number of String allocations/deallocations.
The code is very simple, no object creation at first sight. However my intuition was that it was related to the dictionary Class -> Vector.\<MeshBatch> and a bad implementation in the iOS IOT. Indeed, after testing on Android/Windows, no string allocation.
I stumbled upon this topic that has the exact same issue, string allocation with a dictionary of vectors on ios: https://forums.adobe.com/thread/2088454
In BatchPool, I did a dump of the _batchLists content and noticed that there were only 2 keys: MeshStyle & DistanceFieldStyle, so a simple fix was to add 2 new vectors and some if/else tests to directly use these vectors instead of looking them up in the dictionary.
My fix:
The effect is quite obvious as you can see on these 2 scout recordings:
Before:![batchpool](https://cloud.githubusercontent.com/assets/219800/24095972/d7b88788-0d5f-11e7-9b0f-c49d806e3657.jpg)
After:![batchpool_fixed](https://cloud.githubusercontent.com/assets/219800/24095981/e0727b54-0d5f-11e7-92c4-29418d64b20b.jpg)
Thanks for your work Daniel!
Regards,
Cameron