Higher Cpu usage using Flutter Rive - flutter

I am using Rive file for login animation which requires interaction like SMIBool, SMINumber etc. But when i initialize
final controller = StateMachineController.fromArtboard(artboard.artboard, 'State Machine 1');
if (controller != null) {
artboard.addController(controller);
}
The Cpu usage increase to 50% to 60% on simulator and feels very laggy on real android devices. For reference please check out this attached image
When i comment
artboard.addController(controller)
then cpu usage decrease like 4% to 5%. Please check out the attached image as well.
If somebody knows any fixes. It would be highly appreciated.
Thanks
All answers will be appreciated.

Related

Any lightweight Flutter Network Image plugin for long lists? (up to 500+ image urls to load)

So what I'm looking to achieve is:
Display a long list of hotels, each has one single image url. All these retrieved from an API.
I need it to be smooth/lightweight, so no noticeable fps drops when loading AND scrolling - caching isn't necessary, but if can be implemented without memory problems that'd be cool. (Always have this problem with IOS devices, tested with iphone 6+ I believe)
Options to display placeholder image for when it's loading and when it fails to load regardless of the issue.
What I've tried:
Cached Network Image (the most common solution I find. But memory problems for more than 100+ images. IOS users reports app crashing/closing itself either on scroll or after a bit of loading time. Asked in their github's issues and it seems that this is common problem - still no fix. Tried the suggestions there. Still to no avail.
Advanced Network Image (screen freezes when loading list, probably because it tries to load all image urls at once), also no option for a placeholder image for when an error occurs, not just while the image is loading.
Anyone has encountered similar circumstances and found a satisfactory solution for an acceptable UX? I thought this would be a common enough use case to display a long list of images from network smoothly, but I can't seem to get through this for so long. Pardon me, but I'm a relatively new mobile dev starting to learn the ropes on my own. Any help would be much appreciated. Thank you in advance.
You are caching a lot of stuff at once and that may result in unexpected behavior due to network requests + processing (specially on low end devices).
You can first try increasing the cacheExtent from your ListView to let it start loading before actually reaching the elements and give you a more smooth experience.
ListView.builder(
cacheExtent: 1500, // Play with this offset value, by default is 250 pixels
itemCount: items.length,
itemBuilder: (_, __) => CachedNetworkImage(child: YourWidget()),
);
However, don't increase that value too much because it will force the users to cache content beforehand which may be unnecessary, that's why ListView uses lazy building to load content on demand.
Use memCacheHeight: attribute of CachedNetworkImage along with Cache Extend of ListView, it might solve the problem

Animations Lagging When Publishing from Flash CS6 To iPhone 4

I recently created an app in flash cs6 to be used on my iPhone 4.
The app doesnt need to work through the app store its just a tech demo but when i put the app on my device all the animations become really slow/choppy.
My iPhones up to date and im using air3.2 (i did try updating to air 3.7 but then my application just became a white screen)
I have also tried cacheing all the movie clips as bitmaps bit it doesnt seem to make a difference.
(the app works fine inside the flash simulator)
please help?!
There could be a few reasons why this is happening,as I am taking a punt here as you havent gave much information on what your doing.
but your frame rate may have effect.. how are you creating your tweens?timeline animation or tween scripts.I found tween scripting works better as its distance over time opposed to distance over frames.
Also depending on your animation, images sizes, event listeners etc..
You need to take inconsideration your device itself and the resources it has available, free memory or actual storage available.
The reason it will work freely on your PC would be due to the fact of less limitations, your pc has more to computes and resources to throw at your application .
Add this line to your code to check your memory:
import flash.filesystem.File;
this.addEventListener(Event.ENTER_FRAME,performMemTest);
function performMemTest(e:Event):void {
trace(System.totalMemory);
}
I have read anywhere around 14MB++you may experience problems.

Getting slow perfarmence while playing animation in low memory devices

i'm new to iphone development. im developing app like talking tom. Here im using timers to animate images. for every animation im using separate timer. there is no problem in devices which have more then 5gb free space. But im gettin problem while playing in low memory devices. animation getting slow in those devices. Pleaase help me on this. thanks in advance. Please guide me in right way...
Try to run your timers in different threads.

Weird CPU usage problem when app is backgrounded

I'm experiencing a very weird CPU usage bug with my audio streaming app.
When the app is in the foreground and playing music, the total device CPU usage is only about 15%. However, as soon as the app is put in the background, the CPU usage spikes to 100% and stays there.
About 40% of this is coming from the app process itself, and roughly the other 60% is coming from the SpringBoard process, which apparently handles all Core Animation calls (though I'm not explicitly using Core Animation, I assume that it also handles other UI related activity). Also, according to the "CPU Activity" instrument, most of the additional CPU usage from the app process itself falls into the "graphics" category, though I do see an increase in both the "audio processing" and (strangely) the "foreground app activity" category.
How can I figure out what is causing this problem? Instruments is telling me at high level what is happening, but not why it's happening.
That's extremely odd. However, without any code, it makes it really hard to say anything about anything. Purely based on speculation, I'd say you're updating the UI without knowing it in the background. Perhaps an animation call on -(void)applicationDidEnterBackground? Give us some more to work with! I'm really curious about this now :)
Mystery solved!
Of course I missed the obvious, thank you to Dylan G for pointing me in the right direction. I was running a loop to check the remaining background time. I wasn't sleeping the loop thread at all so it was apparently just running full speed sucking up all CPU power.
I'm not sure why it was looking like it was graphics related and involving the SpringBoard process, but as soon as I added a sleep(1) at the end of the loop, the CPU usage no longer rose when the app was placed in the background. The strange thing is that I'm not calling any UI or graphic related methods in that loop, just calls to [[UIApplication sharedApplication] backgroundTimeRemaining] and accessing some integer and bool properties.
There is still a quick spike of CPU for the second or so after it's placed in the background, and SpringBoard spikes as well, but just for a second, then CPU usage drops back to the same as when the app is running.

Getting Framerate Performance on iPhone

I've just come off the PSP where performance testing was easy. You just turned off 'vsync' and printed out the frameratem, then change something and see whether the frame rate goes up or down...
Is there any way to do the same thing on the iPhone? How do you turn vsync off? The Instruments tool is next to useless. Its chief problem being that it running it adversely affects the performance of the app! Also, the frame rate it reports is extremely sporadic.
I don't want any fancy tool that reports call trees and time spent in each function. I just want an unrestricted frame rate and some way to see what it is. Is there a high precision counter that you can use on the iPhone? Something like QueryPerformanceCounter in windows?
Also, is there anyway for you to somehow KILL backround processes so you know they can't effect the performance, perhaps solving the sporatic frame rate problem?
Profile your app with Instruments and use the Core Animation instrument. It gives a frame rate.
You're taking the try-something-and-measure approach. Very indirect. It's easy to tell exactly what is taking the time; it doesn't depend on what else is going on and doesn't require learning a new tool. All you need is a debugger that you can interrupt.
You can't kill background processes on the iPhone. That would make it possible for a buggy or malicious app to interfere with the phone function and the needs of all other functions on the iPhone are subordinated to the phone.
Try QuartzDebug or OpenGL Profiler.
Use instruments to get the frame rate.
To do this, run profile on your app (click and hold on the run button in xcode and choose profile). Make sure you are running your app on device. Choose openGL ES analysis. Look at the data display under core animation frames per second.
You want to aim for 60fps.