question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix slowdowns when navigating

See original GitHub issue

Continued from https://github.com/fsprojects/Fabulous/issues/373#issuecomment-480486017

I just tried the AllControls sample on my Android device (release mode) and WPF on my beefy desktop computer. There are fairly noticeable slowdowns when navigating on Android, and less so (sub-second, but still noticeable) on WPF. After a cold start on Android, navigating to TabbedPage 3 takes around 2 seconds. I have a hard time imagining clients/employers (or users) accepting that, regardless of maintenance/agility benefits of an Elmish architecture.

  • What is the root cause of the navigation slowdown, particularly on Android?
  • Which factors influence it? (Devices? Model size? etc.)
  • Can anything be done about it? What?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TimLarivierecommented, Nov 22, 2019

Does reflection slow down the performance?

Yes, reflection can slow down performance. But you will only notice performance issue if you make intensive use of it. Individually, it’s not that bad.

That’s why we tried to limit reflection to a minimum in Fabulous.XamarinForms.

The line you’re referencing is one of the few (if not the only one) to use reflection. So I don’t think it’s the source of the slowdowns…

Instead, I think we’re a bit too heavy on the memory. Every time I noticed slowdowns, a corresponding output in the console indicated the GC triggered. GC pauses the app for several milliseconds, enough to make it noticeable sometimes.

So we either don’t clean up enough memory, or we’re instantiating too many small objects that clutter up the memory forcing the garbage collector to pass.

This seems to fit because iOS is not plagued by those slowdowns, while Android takes it fully. On iOS, it’s fully native no GC (only reference counting) - on Android, there’s 2 of them (.NET GC and JVM GC)

1reaction
cmeerencommented, Apr 16, 2019

Note that the AllControls app has not been performance optimized, i.e. there are relatively few dependsOn calls which are pretty much necessary to get good performance for incremental view update.

Does that explain the poor performance when navigating, but much better performance at the page after navigation?

A more general question is how we might best guide the user as to the best place to insert dependsOn calls.

For example, could there be a mode (or Debug mode) that reports when large parts of the View tree re being re-created (as objects) but are in fact identical (and perhaps even relate this to exact source line locations or stacks where the uppermost invariant ViewElements were created?)

I like the idea. The question is how to set the thresholds so the warnings are real and not spammy.

Also, I think clear documentation can get you far on its own. 😃

Note also I don’t think dependsOn is the only way to avoid recomputation of view sub-trees under invariant sub-models., it’s just one relatively simple way. I’d like to hear of other suggestions and hacks that do this.

Some kind of Key property might be good for collections. It would allow you to do smarter differential update of collections, regardless of element ordering. AFAIK it’s an important optimization in React (they throw warnings at you if you don’t supply it in collections), see the React docs on reconciliation. Not sure how easy it is though, given that you can add any attribute to any HTML DOM element, but here we are working with objects with a limited set of properties.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Input Lag and Slow Performance in Google ...
Close running programs and tabs that aren't in use. Clear Chrome's cache and cookies. Disable browser extensions and refresh the page. Turn off ......
Read more >
Google Maps: Missing your turns? Here's how to fix ...
Q: I'm using Google Maps for driving directions in an unfamiliar city and it's lagging which is causing me to miss my turns....
Read more >
Helpful Fix for Laggy gesture navigation : r/android_beta
I found that if you force stop Pixel Launcher and clear the cache for it, the gestures go back to normal.
Read more >
How to Reduce & Fix Gaming Lag
Fix Game Lag by Boosting Your Wi-Fi.
Read more >
Android Auto laggy and slow when using Spotify + ...
When first connecting my phone to my car and starting up Android Auto, everything seems smooth and fluid. However, after a few minutes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found