-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mitigate perf degradation cause by loading wallet-standard #16868
Conversation
d9476cd
to
a173a77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS++
@@ -211,6 +211,9 @@ interface SolanaProvider { | |||
=> (SolanaProviderError error, string error_message, | |||
mojo_base.mojom.DictionaryValue result); | |||
|
|||
// DO NOT USE: This is supposed to be a temoprary solution for us to decide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
// DO NOT USE: This is supposed to be a temoprary solution for us to decide | |
// DO NOT USE: This is supposed to be a temporary solution for us to decide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -600,6 +600,12 @@ void SolanaProviderImpl::Request(base::Value::Dict arg, | |||
} | |||
} | |||
|
|||
void SolanaProviderImpl::IsSolanaKeyringCreated( | |||
IsSolanaKeyringCreatedCallback callback) { | |||
std::move(callback).Run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add DCHECK(keyring_service_);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -68,6 +70,10 @@ JSSolanaProvider::JSSolanaProvider(content::RenderFrame* render_frame) | |||
*g_provider_solana_web3_script = | |||
LoadDataResource(IDR_BRAVE_WALLET_SOLANA_WEB3_JS); | |||
} | |||
if (g_wallet_standard_script->empty()) { | |||
*g_wallet_standard_script = LoadDataResource( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to cache LoadDataResource()
returned values?
If we need, then it should be shared memory for all the renderer. Otherwise it takes 1.8MB(the string size) per renderer process because it's private process memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For large resources:
- If the resource isn't gzipped use
GetRawDataResource()
each time, don't cache; - If unzip time is affordable don't cache, use
LoadDataResourceString()
each time (except large resources on UI thread in browser process); - Store cached unzipped resources in browser process. Pass them via IPC each time you need it. Or store it in shared memory and pass a handle.
Bad practice:
- Using private process memory to cache
LoadDataResourceString()
(i.e. static std::string) for large resources. It increases total footprint byRESOURCE_SIZE * N
whereN
is renderer process number. Also each new tab usually uses a new process => old cache doesn't help to save time. - Loading large zipped resources on UI thread. It will result in freezes/frame drops: crbug.com/973417
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case all 3 cached resources are unzipped => please use GetRawDataResource()
each time, don't cache.
P.S. I wonder could we support gzip in transpile_web_ui.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those cached scripts resources are removed and they are only be used once, I don't think they need to be cached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after removing the resource cache.
2613037
to
31fd637
Compare
31fd637
to
2c655a2
Compare
Mitigate perf degradation cause by loading wallet-standard
Resolves brave/brave-browser#27997
We now load wallet-standard script separately in
OnFinishLoad
and only when Solana keyring is created.follow-up issue created: brave/brave-browser#28082
iOS now needs to load new script
IDR_BRAVE_WALLET_SCRIPT_WALLET_STANDARD_SCRIPT_BUNDLE_JS
in order to get wallet-standard compatibility and also callIsSolanaKeyringCreated
to decide whether to load wallet-standardRelease build comparison on example.com: (Reland: v1.49.56, No wallet-standard: v1.48.110)
task (compile time + function call) is delayed after first paint
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Fresh profile
--user-data-dir
can be used so you can open them simultaneously)Function(anonymous) @ wallet_standard.js:1:10
) + Compile time appeared after FP and FCPWith Solana account created
--user-data-dir
can be used so you can open them simultaneously)Function(anonymous) @ wallet_standard.js:1:10
) + Compile time ahead of it should be similar to previous version ofFunction(anonymous) @ solana_provider.js:1:10