-
Notifications
You must be signed in to change notification settings - Fork 868
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
Fixed redundant creation of Default profile #13929
Conversation
@@ -120,7 +120,7 @@ BraveStatsUpdater::BraveStatsUpdater(PrefService* pref_service) | |||
BraveStatsUpdater::~BraveStatsUpdater() {} | |||
|
|||
void BraveStatsUpdater::OnProfileAdded(Profile* profile) { | |||
if (profile == ProfileManager::GetPrimaryUserProfile()) { |
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.
Wow, there is a comment that this method should not be used in desktop.
// WARNING: do not use this function on Desktop platforms (Windows, Mac,
// Linux). See https://crbug.com/1264436 for more info.
// TODO(https://crbug.com/1264436): restrict this function to Android and
// ChromeOS.
Is there any possibility to introduce regressions from this change? cc @bridiver
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.
Wow- nice find, @spylogsster @simonhong. So we were using a bad method this whole time?
I think the re-creation of the deleted folder was the regression 😄
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.
The fundamental problem here is that we're assuming a single profile and there's really no good way to do this. We're comparing it against the P3A data to see if we can drop this entirely, but if we want to collect a few more months of data first I'm hesitant to make any changes that will introduce another variable into the equation
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.
// WARNING: if the profile does not exist, this function creates it
// synchronously, causing blocking file I/O. Use GetLastUsedProfileIfLoaded()
// to avoid creating the profile synchronously.
static Profile* GetLastUsedProfile();
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.
false alarm, it does not recreate the default profile
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.
Changed to use GetLastUsedProfileIfLoaded
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.
it will recreate the default profile if all profiles have been deleted so probably GetLastUsedProfileIfLoaded
is the way to go because it should not have any side effects
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.
Changes LGTM! ++
@DJAndries how do things look for you? This would be a great fix to land if everything is OK
looks good! will do a smoke test today |
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.
The stats updater works OK with the suggested change above.
Also, has anyone seen this stack trace when exiting the browser?
Received signal 11 SEGV_MAPERR 000000000008
#0 0x557394fa16c9 base::debug::CollectStackTrace()
#1 0x557394ebaa93 base::debug::StackTrace::StackTrace()
#2 0x557394fa1181 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f69cddf88e0 (/usr/lib/libc.so.6+0x3e8df)
#4 0x55738fba85e9 base::ObserverList<>::RemoveObserver()
#5 0x557394bfa064 (anonymous namespace)::AdBlockSubscriptionDownloadManagerGetterImpl::OnProfileManagerDestroying()
#6 0x557394b74ad7 ProfileManager::~ProfileManager()
#7 0x557392a77a22 BraveProfileManager::~BraveProfileManager()
#8 0x557392a770ae BraveProfileManager::~BraveProfileManager()
#9 0x5573949e3c68 BrowserProcessImpl::StartTearDown()
#10 0x5573949e272a ChromeBrowserMainParts::PostMainMessageLoopRun()
#11 0x557391680ac1 content::BrowserMainLoop::ShutdownThreadsAndCleanUp()
#12 0x55739168299a content::BrowserMainRunnerImpl::Shutdown()
#13 0x55739167e307 content::BrowserMain()
#14 0x55739496d7f5 content::RunBrowserProcessMain()
#15 0x55739496f184 content::ContentMainRunnerImpl::RunBrowser()
#16 0x55739496ec00 content::ContentMainRunnerImpl::Run()
#17 0x55739496c34c content::RunContentProcess()
#18 0x55739496c43e content::ContentMain()
#19 0x55738f9b4233 ChromeMain
#20 0x7f69cdde3290 (/usr/lib/libc.so.6+0x2928f)
#21 0x7f69cdde334a __libc_start_main
#22 0x55738f9b402a _start
r8: 000030e4005e4120 r9: 0000000000000000 r10: 00007ffd314ed080 r11: 00000000008328cc
r12: 00007ffd3147e730 r13: 00007ffd3147e750 r14: 0000000000000008 r15: 000030e400b19860
di: 0000000000000008 si: 000030e400b19860 bp: 00007ffd3147e6a0 bx: 000030e400b19860
dx: 0000000000000000 ax: 0000000000000000 cx: 0000000000000001 sp: 00007ffd3147e660
ip: 000055738fba85e9 efl: 0000000000010206 cgf: 002b000000000033 erf: 0000000000000004
trp: 000000000000000e msk: 0000000000000000 cr2: 0000000000000008
[end of stack trace]
Now, if I open the wallet, and close the browser in less than 30 seconds, the updated last usage time stored in the profile prefs is not persisted.
@@ -120,7 +120,7 @@ BraveStatsUpdater::BraveStatsUpdater(PrefService* pref_service) | |||
BraveStatsUpdater::~BraveStatsUpdater() {} | |||
|
|||
void BraveStatsUpdater::OnProfileAdded(Profile* profile) { | |||
if (profile == ProfileManager::GetPrimaryUserProfile()) { | |||
if (profile == ProfileManager::GetLastUsedProfileIfLoaded()) { |
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.
Can we change this instance to GetLastUsedProfile
instead? GetLastUsedProfileIfLoaded
seems to always return a null pointer when called from OnProfileAdded
.
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.
@bridiver wdyt?
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.
That's still going to create side effects. Can we compare profile->GetPath() == GetLastUsedProfileDir()
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.
done
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.
Just smoke tested, there's a bug with this approach. Steps to reproduce (assumes you have two profiles, and a log within the if block):
- Open browser, open first profile, close
- Open again, open first profile, see the log, close
- Open again, open second profile, the log is missing, close
- Open again, open second profile, the log now exists
This doesn't happen with GetLastUsedProfile
.
@@ -214,7 +214,7 @@ BraveReferralsService::BraveReferralsService(PrefService* pref_service, | |||
BraveReferralsService::~BraveReferralsService() {} | |||
|
|||
void BraveReferralsService::OnProfileAdded(Profile* profile) { | |||
if (profile == ProfileManager::GetPrimaryUserProfile()) { | |||
if (profile == ProfileManager::GetLastUsedProfileIfLoaded()) { |
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.
The same may apply here.
The crash goes away if I remove |
2d27d6c
to
2ef3f5a
Compare
@@ -102,10 +104,11 @@ class AdBlockSubscriptionDownloadManagerGetterImpl | |||
} | |||
|
|||
void OnProfileManagerDestroying() override { | |||
g_browser_process->profile_manager()->RemoveObserver(this); | |||
profile_manager_->RemoveObserver(this); |
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.
this code is called from ProfileManager destructor when g_browser_process->profile_manager()
is null already.
cc @antonok-edm
fixed |
be6a5a4
to
9779fba
Compare
3271756
to
e73b6ab
Compare
64a91f2
to
7106b3b
Compare
6d084ab
to
fec2cc1
Compare
5230f52
to
d2f164e
Compare
8d327da
to
31c05bd
Compare
8929d8e
to
c3aa619
Compare
c3aa619
to
cceed7f
Compare
cceed7f
to
1f8b1ce
Compare
Resolves brave/brave-browser#4599
Fixed redundant creation of default profile.
GetPrimaryUserProfile
returnsDefault
browser profile, but not the profile which is currently used by user. If user has deletedDefault
profile it will be re-created in this case. Better to use LastUsedProfile which returns current profile for the user.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
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: