Skip to content

Android App start-up HUGE improvement#2194

Draft
uzzyDC wants to merge 2 commits intofloccusaddon:developfrom
uzzyDC:develop
Draft

Android App start-up HUGE improvement#2194
uzzyDC wants to merge 2 commits intofloccusaddon:developfrom
uzzyDC:develop

Conversation

@uzzyDC
Copy link
Contributor

@uzzyDC uzzyDC commented Mar 6, 2026

#2170 Removed hash calculation during android native app start up. Hash is not required prior loading tree view, but only prior remote sync to check for differences.
Start up time from 10-15 seconds to 0.1 seconds with 5k bookmarks and sd 8gen2.

… time from 10 seconds to 0.1 seconds with 5k bookmarks and sd 8gen2. Hash is not required prior loading tree view, but only prior remote sync to check for differences.
@uzzyDC uzzyDC marked this pull request as draft March 7, 2026 09:51
@uzzyDC
Copy link
Contributor Author

uzzyDC commented Mar 7, 2026

I think I introduced an issue with andoid app sync, I'm checking Native/Action.js to fix it.

@marcelklehr
Copy link
Member

I've tried to achieve the same thing with fewer changes, but didn't have time to test if this actually works: #2195

@uzzyDC
Copy link
Contributor Author

uzzyDC commented Mar 7, 2026

The fact is that NativeTree.load() Hash calc should be ignored only for app startup calls, when the tree view is loaded. The following calls behaviour should remain the same, reason why I introduced a skipHash parameter, which should have default value false (last commit on my branch).

NativeTree.load() is invoked in actions.js and NativeAccount.get().
I'm skipping hash only in NativeAccount.get(), which however I'm not 100% sure is called only at startup. Anyway, a deeper refactoring is probably required to handle properly this mod, need to get used to the codebase.

@uzzyDC
Copy link
Contributor Author

uzzyDC commented Mar 7, 2026

I've tried with your code (plus console.log() to debug), NativeTree get executed twice at start-up (don't know why, I have only 1 profile).
Then I force SYNC_DOWN, but it never gets called again.
Sync starts but never ends.
Don't know.

image

@marcelklehr
Copy link
Member

NativeTree get executed twice at start-up (don't know why, I have only 1 profile)

That's likely a race condition, we might be able to prevent this by using a lock

Then I force SYNC_DOWN, but it never gets called again.

Why would it be called again?

Sync starts but never ends.

I cannot reproduce that, for me #2195 works

const newHash = await this.bookmarksCache.hash(this.hashSettings)
// this.bookmarksCache.cachedHash = newHash
// await Storage.set({ key: `bookmarks[${this.accountId}].treeHash`, value: newHash }) // optionally persist hash
this.highestId = parseInt(highestId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highestId also needs to be set when skipHash is true

return false
}
else {
// oldHash = this.bookmarksCache?.cachedHash ?? await this.bookmarksCache?.hash(this.hashSettings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit commented-out lines, it makes things hard to read ;)

"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chrome-webstore-upload": "^0.4.2",
"cross-env": "^10.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency addition seems unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on windows, not sure is really needed, but I didn't want to push it.

"isomorphic-git": "1.x",
"js-base64": "^3.7.5",
"lodash": "^4.17.20",
"oboe": "^2.1.7",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, unused, it seems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants