Open Murilo-Perrone opened 6 years ago
Notes: A - This is only supported by ES2017, but babel will transpile it to ES2015 so it is compatible with all devices, and with any other javascript transformations. It improves the code a lot without locking up the UI thread. Allows a single outer try-catch block to capture anything in the execution stack / sequence, plus a finally block. That makes things unit testable.
B - I have implemented that through "caching enabled data provider classes", which inherit form a cache manager base class. I can provide typerscript examples of this pattern.
For a full fix with minimal effort, I'd suggest migrating it to React Native,
:rofl:
Since you seem to know about javascript, instead of telling me to rewrite the application, you could try to debug it on your phone. I know it is slow on zenphone, but I don't own one, so you'd be helpful.
Hint: The app is responsive on other phones. Zenphone uses an Intel chip, I don't blame the chip but maybe there is an issue with webview on intel phones?
Sorry, didn't mean to be dismissive about this great piece of work. I just don't think a Cordova based application can will ever be responsive enough for a bullet game. In ionic applications I developed there was also lag in the UI rendering, which I handled with async/await and caching, but in those applications the UI responsiveness wasn't something critical.
I'll find out what makes it so slow in my phone, but I believe that to some extent all phones are affected by the Cordova platform (as per see #615). Anyone with similar results as I had will likely give up on using this app and try something else. So I mentioned React Native because it allows javascript+node development and the existing ReactJS pages can be shown in WebViews (link). I don't have react experience, but based on that do you think a smooth transition is possible ? Or not ?
IDK about Asus Zenfone, but it's fast enough for bullet on my phone - Moto G4 Play - Android 6
I know that react-native is better, but it is definitely not a smooth transition, it is almost a full rewrite. Still, the application is playable as is, even with fast time control.
Thanks for changing the title btw. I'll add the "help wanted tag" for the record, and if you can solve this issue it would be awesome. Again there should be no need to change the code, it runs fast enough on other phones.
In my Asus Zenfone 5, this has always been the most unresponsive app I have ever seen. It takes several seconds to do any UI update, such as showing the menu or updating the board. I can't ever watch a bullet game, it's irritating. Even for puzzles and correspondence games, I still need a lot of patience. It has always been that bad, even o high speed internet.
This is mostly because Javascript is single-threaded by nature and the code is initiating a large quantity of asynchronous code, thus creating a lot of CPU competition. Also, it is a language of poor performance.
For a full fix with minimal effort, I'd suggest migrating it to React Native, as it renders the UI in a separate thread. And it offers better performance by focusing on running as much as possible in native code.
To just make things a little better, I'd recommend:
A - Eliminate all promise then/catch blocks by using async/await keywords. That will eliminate any unnecessary parallelization of execution, thus reducing the CPU competition (so UI thread will get a larger slice).
B - Start to cache information. Instead of reading it over and over from the server, each information read should have a time-to-live, whose interval depends on the content. Withing that interval, the app uses cached information instead of making a new server request.