brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.06k stars 2.23k forks source link

[perf] braveEthereum and braveSolana inject on an empty profile #35237

Open atuchin-m opened 6 months ago

atuchin-m commented 6 months ago

Currently we always inject braveEthereum. We should inject only when user have a wallet initialized.

image

brave_etherium_inject.txt

bbondy commented 6 months ago

So basically this is how it should work:

For users without a wallet created: Onboarding process should be launched for EIP 6963 capable dapps. window.ethereum and window.braveEthereum should not exist until eip6963:requestProvider

For users with a wallet created: window.ethereum, window.braveEthereum should always be created. Same as now.

darkdh commented 1 month ago

Since there is no Solana issue for that, merged the info into this.

For users without a wallet created: Onboarding process should be launched for wallet-standard capable dapps. window.solana and window.braveSolana should not exist until wallet-standard:app-ready

For users with a wallet created: window.solana, window.braveSolana should always be created. Same as now.

atuchin-m commented 1 month ago

@cypt4 @darkdh My idea was to make those javascript injection on demand even for Wallet users. JS concept is here: https://davidwalsh.name/lazy-object-initialization We could:

  1. make a stub using C++
  2. when the stub is accessed the first time we inject the real javascript that replaces the stub to to a real impl. All the things suppose to happen synchronously in C++ getter. The caller will get the real object.
  3. the page javascript calling window.braveSolana can't see any difference.