moontreeapp / moontree

Primary Mono Repo
6 stars 5 forks source link

splashscreen hangs before login #573

Closed lastmeta closed 2 years ago

lastmeta commented 2 years ago

Describe The Bug

splashscreen to create password page works well, but once you have a login and the database has content in it, the splashscreen hangs for a few seconds before showing the login screen.

lastmeta commented 2 years ago

on login timing for database.setUp()

I/flutter ( 1466): registerAdapters: 0:00:00.011468
I/flutter ( 1466): init------------: 0:00:00.038255
I/flutter ( 1466): openAllBoxes----: 0:00:01.147646
I/flutter ( 1466): beforeLoad------: 0:00:01.147935
I/flutter ( 1466): after load------: 0:00:07.747662

loading is probably where that hang happens... lets compare to the create process.

I/flutter ( 4791): registerAdapters: 0:00:00.011789
I/flutter ( 4791): init------------: 0:00:00.039871
I/flutter ( 4791): openAllBoxes----: 0:00:00.188728
I/flutter ( 4791): beforeLoad------: 0:00:00.189072
I/flutter ( 4791): after load------: 0:00:00.217759
lastmeta commented 2 years ago

broke it into parts and ran separately, one part on splash and one part on login, perhaps we can optimize it a bit more, but I think the biggest speed up will be avoiding download of vouts that are not needed.

lastmeta commented 2 years ago

I/flutter (14333): VOUTS COUNT1: 12478 after downloading dangling transactions I/flutter (14333): VOUTS COUNT2: 54429

lastmeta commented 2 years ago

ok, I bleive we can avoid downloading dangling tx vouts now because we no longer get our totals from there. after filtering out all the unnecessary vouts with this code:

    var x = res.vouts.data.toSet();
    x.removeAll(res.wallets.map((w) => w.vouts).expand((i) => i).toSet());
    x.removeAll(res.wallets
        .map((w) => w.transactions)
        .expand((i) => i)
        .map((t) => t.vouts)
        .expand((e) => e)
        .toSet());
    x.removeAll(res.wallets
        .map((w) => w.vins)
        .expand((i) => i)
        .map((v) => v.vout)
        .toSet());
    print(x.length);
    await res.vouts.removeAll(x);

we were left with 12478 vouts. those are needed to know what our transactions were - burned, reissue, etc. so. we'll keep those, but I belive this will reduce the load times by a few seconds without any negative side-effects :)

I/flutter ( 3794): beforeLoad: 0:00:00.639820
I/flutter ( 3794): after load: 0:00:02.470457

yeah its a 3 second wait now, instead of an 9 second wait. going to revert to compare transactions amount and verify there are no side effects