I am creating a game in Flutter that is mostly about dices. To make the background of the main menu interesting and dynamic i added a few blurred animated dices. I also use these animated dices elsewhere in the game. Something like this:
I started off using Flare as an animation library, but the performance was very bad. (using this animation).
After that I recreated the animation as a Flutter widget. However the performance is still very poor. On a OnePlus 3 I am getting somewhere around 30-40 fps and on a Galaxy s20 (in 120hz mode) somewhere around 50-60fps. Underneath are the frame rendering times for the OnePlus. Offcourse I am testing in Profile mode. Mainly the Raster thread is doing a lot of work here.
Here is a github repository with the code. This is a minimalistic version to reproduce the performance problem.
As far as i can see there are no unnecessary rebuilds. The only thing that is rebuild very often is the SlideTransition (This line) for the dots.
What can i do to improve the performance? Or what can i try to profile it. I have noticed that removing the Transform.rotate (this line) helps, but it does not solve the problem completely.
I am using Flutter 1.20.2 and Dart 2.9.1 in Android Studio 4.0.1
Related
On Android, when translating off-screen components onto the screen, it takes a very long time. When the function to bring them on-screen is triggered, it seems to completely block the main thread for (almost a) second. I am only rendering 100 simple elements and iOS can handle it even with a much greater pixel density. On Android, this issue is reproducible for me even on a high end phone.
I have created a minimal repo here: https://github.com/darajava/render-bug-android-react-native
See these 2 videos for a comparison of how Android vs iOS handles it:
Android: https://youtu.be/KBP2HHMzAiU
iOS: https://youtu.be/fw-Prh_9HhY
I created a react native issue here: https://github.com/facebook/react-native/issues/30987
Am I doing something wrong? Is this a bug in RN? If so, is there a workaround I can use?
I have a bug plaguing my project that I can't find any resources to online. There are 2 scenes in my app, Menu and Game. Menu has this behavior 100% of the time, whereas Game only loads with this glitch occasionally. It appears that once it happens once in Game, it will happen multiple times consecutively, and then eventually fix itself. Here is the image of what I am seeing: Menu scene --- Game scene
There are no scripts on my Canvas that are not standard Unity scripts, everything is stock. I have also checked the logcat log via command prompt and no errors are thrown.
If you have any information as to why this glitch is happening, please let me know. I think it has something to do with Canvas settings or a missing dependency/package conflict, but no settings that I changed caused the glitch to go away. Thank you for the assistance!
Change UI Scale mode of canvas to scale with screen size instead of constant pixel size
Answered my own question.
If you are making an AR app and have UI in the app, you NEED a regular Unity Camera in the scene alongside your AR Camera. The AR Camera should be tagged 'Main'.
For some reason, UI cannot attach to AR cameras, and while I don't understand why, the solution still works.
I am currently working on an android game in Unity. In the editor everything looks great, actor moves smoothly, generated dungeon looks nice. After building the game and start it on my smartphone the whole dungeon looks different and when moving my actor I can notice strange vibration that has never appeared before. While vibration my be caused by "wrong" implementation(I am working on very powerful Desktop so the code may be not optimal), the strange arrangement of dungeon is not about implementation at all. I tried building same version on web player and it looks jut as in editor. Look at the differences between Android-Standalone builds.
Android: http://imageshack.com/a/img901/5057/7REtUn.png
Standalone: http://imageshack.com/a/img661/2618/2Em05d.png
As you can see standalone build is just as expected, nice corridors and chambers, while on android... chaos?
EDIT: While using Unity Remote everything looks fine. Well movement isn't okay but as I said am sure now it is caused by implementation. But generated dungeon keeps unsolved.
Have you tried adjusting your targeted frame rate? Maybe your targeted frame rate is set improperly for your specific device. You may also want to try lowering the native resolution . If your resolution is really high it will cause choppiness and lag. Another item I also had to tweak to get my game to run well is the Lighting Options. From forward lighting you can change to vertex lit and it substantially speeds things up.
You may also want to mess with your shaders a bit, and see what mobile options you can go for. Various shaders have different outcomes, also rendering paths effect how things look. Are you using OpenGLS 2.0, 3.0, specifically look the settings from standalone to mobile in Player Settings.
Also make sure you're using the new Unity Remote as opposed to the old version. The old version works through wifi which is slow, the new one uses tethered USB and is relatively well.
To adjust the screen resolution as I mentioned above I had to:
75% resolution (landscape):
Screen.SetResolution (Screen.width * 0.75f, Screen.height * 0.75f, true);
To adjust target framerate as mentioned above:
Application.targetFrameRate = 60; //sets framerate to 60.
I am developing a native Android app using the JUCE C++ framework. The app is rendering using OpenGL. Non-interative animations perform very well.
However, interactive touch-responsive animations e.g. dragging a component are slow to update. It is not at all smooth. I measured on the Java side and its averaging around 70-80 ms or so between each ACTION_MOVE event.
UPDATE: I think the main issue may be to do with rendering whats
underneath the component being moved. When I tried out the JuceDemo,
using the Window demo I found I had bad performance dragging a window
over another, but if I drag the window around where there is only
empty space, it performs fine and feels smooth.
Is there a way I can increase the animated UI responsiveness in my app?
I've made some changes to the standard Java template provided by the Introjucer so that the native handlePaint() function is not called when there is an OpenGL context. (as suggested here)
When I use AdMob in my activity it is slowing down all my other view animations, introducing artifacts on them and so on. Did anyone have this and was able to somehow solve it?
UPDATE: I have a really old Nexus 7 with Android 4.4.2 and it was running everything perfectly smooth. Then I upgraded it to Android 4.4.4 and it started to show that crappy performance + artifacts. What could have changed there in this small update from 4.4.2 to 4.4.4??
We have had this issue on a couple of our games. The problem in our case was as follows.
The game itself had a bunch of layers to accommodate all the animations, and the Ad later was on top of the game layers, this messed up the renderer as it had to cater for the ad while rendering the scene. We had to hide the ad during game play to ensure full speed animation. An alternative was to adjust the size of the animation layers to ensure that they did not overlap the ad layer, but we did not go that route as our home grown framework did not support that.
Hope that helps.