Closed hardcoremore closed 6 years ago
The Array and String allocation cannot be avoided. I might be able to try some things to avoid the MethodClosure allocation, but I cannot guarantee that it will be possible.
Currently this is the biggest memory allocator in my game.
Most likely my extensive use of === and !== in Feathers (including #1726) is actually the main cause of your memory allocations.
After learning that using === and !== with numeric values causes allocations that cannot be seen in Scout, I've been planning to clean that up when I get a chance. It may take some time, but I'll get to it.
What could be the reason for allocating strings so much on iOS only in advanceTime method. I know that strings are allocated on iOS when you are using vectors and dictionary or object but they are not used in advanceTime? What is there specific for iOS only that allocate so much strings.
Is it possible that you push quick commit for just a couple of them === and !== that are used the most and or every frame like the one in advanceTime so that I can build that feathers version.
Also is it possible that I help you somehow in converting those === !== to speed things up.
Thanks
It's the call to this._starling.contextValid
that is allocating a string. As I recall, in AIR on iOS, every call to the driverInfo property on Context3D allocates a string. Unfortunately, I cannot avoid checking if the context is valid every frame.
Josh but why do you need to check if context is valid every frame. Is it possible that context is invalidated silently?
What about Event.CONTEXT3D_CREATE to check if context is restored?
Why Starling does not check contextValid every frame?
I just saw that Starling also checks every frame if context is valid.
So Starling checks if context is valid every frame and if it is not valid the juggler will not run so there is no need to check it twice.
I just saw that Starling also checks every frame if context is valid so that is not allocating strings for sure.
Yes, it is.
So there is no need to check it twice, right? And as I am looking in the Adobe Scout profile contextValid could actually allocate those Strings because there is a difference of about 1200 Strings allocations between Starling.advanceTime and ValidationQueue.advanceTime.
But can we just drop that check in ValidationQueue.advanceTime since Starling is already checking it.
So there is no need to check it twice, right?
Feathers has no way to access the value returned when Starling checked it. Even if that were possible, it's possible for Stage 3D to lose context between when Starling checks the value and when Feathers does.
Some allocations are simply impossible to avoid. You can do your best to avoid the ones you have control over, and this is not one of them.
But what is the worse case that can happen if context is lost and ValidationQueue.advanceTime is run? Run time exception? Because the context is so rarely lost on iOS. I think that in these 2.5 years I only experienced 1 context loss on iOS.
Yes, a runtime error can be thrown if a component tries to do something with Stage 3D when the context is lost during validation.
Ok than, I than I will disable that check manually for iOS only when I build feathers because loosing context is so super rare on iOS that I do not even care if app crashes.
Is there an easy way to check if platform is iOS inside ValidationQueue.advanceTime() method?
This should work
if(Capabilities.version.indexOf("IOS ") == 0)
{
}
I am just wondering what is the story behind that space "IOS " :D why is that needed?
Thanks for the help Josh. If I can help something with the repeating work of replacing === and !== for integers and numbers let me know. Currently the most important ones are the ones that are used on every frame.
I am just wondering what is the story behind that space "IOS " :D why is that needed?
It's better to be safe than sorry!
@hardcoremore Can you try my latest commit and verify that you no longer see the MethodClosure allocation in ValidationQueue.advanceTime()?
Josh,
Unfortunately, with the Windows PC that I am currently using connection to Adobe Scout is not possible because it is not working for some reason. I do not know why. But I will definitely check tomorrow and get back with the results.
Josh,
I can confirm that MethodClosure and Arrays are no longer allocated on iOS in ValidationQueue.advancedTime. Just a couple of strings and objects. Take a look at Scout profile screenshot:
Also you were right, checking driver info does allocate strings in iOS. You can see Strings are no longer allocated once I disable that check for iOS only.
Thanks
Hi Josh,
ValidationQuee.advanceTime method is creating too much Array, MethodClosure and String instances.
But different things are allocated for different platform.
For Android Platform there are a lot of Array and MethodClosure instances. Take a look at the screenshot of Samsung Galaxy s6 Edge Adobe Scout Profile:
https://ibb.co/n9dx6T
For iOS all three Array, MethodClosure and Strings instances are allocated a lot. Take look at the screenshot of iPhone X Adobe Scout Profile:
https://ibb.co/n3z4mT
On the Desktop PC there are only just a lot of Strings allocated in BitmapFontTextRenderer.measureTextInternal(). Take a look the Adobe Scout profile screenshot :
https://ibb.co/jEi3fo
Here are the Adobe Scout profiles of all three platforms:
Android: http://bit.do/egPJJ
iOS: http://bit.do/egPRM
Deskopt PC: http://bit.do/egPRX
Is there something that can be done to optimise this. It is affecting performance on weaker devices.
Currently this is the biggest memory allocator in my game. Can you please look at it.
Thank, Caslav