Forum Xamarin.Forms

The application may be doing too much work on its main thread.

Miki93Miki93 DOMember ✭✭

Well, first than nothing, i dont speak english very well. Sorry if i write anithig wrong.

Well, I'm developing an app, and I have several weeks working in this 'project', today I realized that my app have a poor UI, becose, it freeze sometimes, for example when I navigate to another page, or fill a ListView component, and in all pages the consele throw me this: I/Choreographer( xxxx ): Skipped xx frames! The application may be doing too much work on its main thread..

These are two examples of my problem:

NAVIGATING TO ANOTHER PAGE

FILL A LISTVIEW COMPONENT

i tried use several solutions but nothing worked :(

To avoid that the listview component getting cold, I tried this:

public async Task Async_llenarListView(){
await Task.Run(() => {
string[] _equipos = { "Los Angeles Lakers", "Golden State Warriors", "Boston Celtics"};

            for (int i = 0; i < _equipos.Length; i++){
                _lista.Add(new model_equipos{
                    _id = i,
                    _source = "team" + (i + 1),
                    _nombreEquipo = _equipos[i],
                    _siglas = _siglas[i],
                    _votos = new Random().Next(0, 100) + ""
                });
            }
        });
    }`

(This example is another ListView Component, don't is the ListView Component of the Second Gif)

To call a Page, i do this now:
private void mc_btn_sinCuentaAsync(object obj){
Application.Current.MainPage.Navigation.PushAsync(new mdp());
}
(When i press the button using the method to call another page in that way the page don't load and the app stay in blank. I can return press the back button)

I don't knows how solve these problems :( i was searching in internet but don't finnded(or find - I don't knows how write it, sorry) nothig that help me.. I need knows how if use Await and Task or Device.BeginInvokeOnMainThread. I'm new with C# and for that i don't know use it very well.

I would like a example about the use of best performance to CrossPlatform App.. please help me :(

Posts

  • Miki93Miki93 DOMember ✭✭

    Oh i forgot anything else,

    I tried this to call another page :

    private async void mc_btn_sinCuentaAsync(object obj){
    awake Task.Run(() => { Application.Current.MainPage.Navigation.PushAsync(new mdp()); });
    }

    And for this is my third gif. With my first form mentioned:
    private void mc_btn_sinCuentaAsync(object obj){
    Application.Current.MainPage.Navigation.PushAsync(new mdp());
    }
    The page open nice and show the content, but very slow.

  • Miki93Miki93 DOMember ✭✭

    Well if somebody have the same problem, I "solved" this doing the next:

    Wiht the slow scroll I used the ListViewCachingStrategy and set them with RecycleElement. And my ListView Scroll have a fluid scroll now.

    And The another problem of the app slow when I Press a button, I set a Page with a ActivityIndicator, and in my viewnidel I used a isBusy Property, when the page load the ActivityIndicator set isVisible = false;

    I'm having the same problem with the
    I/Choreographer(xxxxx): Skipped xxx frames! The application may be doing too much work on its main thread.

    But i don't knows how solved it.. I'm using async-await Task.Run wiht my ListViews but.. THE SAME... if Anyone can give me recommendations for solved this problems in a app Xamarin CrossPlatform, amazing.

    I wait that my recommendations can help anyone.

  • denes710denes710 Member ✭✭

    Hello,

    Did you solve your problem ? I have the same problem and I do not know what to do.

    Thank you for your recommendations.

  • Miki93Miki93 DOMember ✭✭

    @denes710 said:
    Hello,

    Did you solve your problem ? I have the same problem and I do not know what to do.

    Thank you for your recommendations.

    well, researching on internet I finded this:

    https://vaibhavtolia.wordpress.com/2013/10/03/79/

    on summary is normal have that's warning, but if is less than 100 of frames skipped.
    In my case only are 88 or less. I solved some cases that was more than 100 frames skiped, using Task.

    I hope this serves you something. :)

Sign In or Register to comment.