cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.21k stars 7.06k forks source link

Slow startup on windows phone 8.1 & windows 10 mobile #15881

Open ishmar opened 8 years ago

ishmar commented 8 years ago

Cocos2d-x by default is really slow at startup on windows phone 8.1 and windows 10 mobile.

I own a microsoft lumia 435 and last time I tried to create a new project, compile and deploy it to my lumia it takes about 5 seconds to start. (Today, using cocos2d-x v3.11.1)

I compile using visual studio 2015 community.

Found that the problem is the time it takes to Angle to transform/compile the cocos shaders. On my game (I use cocos2d-x v3.10 for it) I managed to implement this optimization modifying GLProgram::initWithByteArrays() and GLProgram::link() mainly.

Implementing that optimization reduced my startup time from 5 to 1 second on that device, but that's after second start. First one must precompile and write shaders to device so it's still slow. Being slow on first run has result in many of my users on windows device trying the game, and then quitting while it's starting as they think it's broken or not working, thus uninstalling it and not giving a second chance to see if it runs or not. That's not a desired behavior and that's the reason I believe this isn't a real fix.

Would love to see any other trick/magic on windows port that really improves startup time, and would be nice to see it done on cocos library so every new game people creates benefits from it.

I can clean up and adapt my code for v3.11 branch if needed, but as stated before, I 'believe' that's not the path to follow as I'm interested in good startup times from the very beginning.

Thanks

ishmar commented 8 years ago

I 'think' adding a progress bar with something such as 'Preparing for first run' while precompiling shaders would do the trick too, sadly, my knowledge of XAML isn't good enough to achieve as I need to pass progress information from GLProgram to the progress bar widget that I would create in OpenGLESPage::swapChainPanel.

Btw, I don't have startup times anymore, but I got a Lumia 620 to test my game's first release in Windows Store, and startup time was awful too, that was the reason I decided to add the shader precompilation optimization,... so it happens on all devices, guess it's just that the more powerful the device, the less you'll notice ANGLE spending time on startup.

crazyhappygame commented 8 years ago

+1 I created #15746 , there is also #15637 @ishmar could you create pull request with your update "Caching compiled program binaries"? Is it possible to deliver precompiled shaders with game? How big it is?

crazyhappygame commented 8 years ago

@ishmar could you have a look #15901 ? Do you have similar issue?

ishmar commented 8 years ago

Really busy right now. Will try to clean some ugly code and compile it against v3.11 and create pull request, but need some time :(