Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Only store menu in appState on Windows #9991

Merged
merged 1 commit into from
Jul 17, 2017
Merged

Only store menu in appState on Windows #9991

merged 1 commit into from
Jul 17, 2017

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Jul 14, 2017

... and even then, store only the data (don't serialize functions, etc).

Auditors: @bridiver, @bbondy

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@bsclifton bsclifton added this to the 0.18.x (Release Channel) milestone Jul 14, 2017
@bsclifton bsclifton self-assigned this Jul 14, 2017
if (isWindows) {
const menuDataOnly = JSON.parse(JSON.stringify(template))
appActions.setMenubarTemplate(Immutable.fromJS(menuDataOnly))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not ideal- could use some help finding a better way to do this

}

module.exports.isWindows = () => {
return process.platform === 'win32' ||
(navigator && navigator.platform === 'Win32')
(typeof navigator !== 'undefined' && navigator.platform === 'Win32')
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because navigator is undefined in the browser process (which causes a crash).

@bsclifton
Copy link
Member Author

I can make an issue for this too (if it makes sense)

@bsclifton
Copy link
Member Author

bsclifton commented Jul 16, 2017

OK made some tweaks, ready for re-review @bridiver @bbondy

Here are some important notes:

  • This PR updates to only store menu in appState on Windows
    • functions are stripped out (will no longer be serialized)
    • with a few thousand bookmarks, the initial stringify/parse takes ~60ms and is never done again (until you quit / relaunch Brave)
    • menu (if present) is now deleted from appState when saving session / exiting browser

Some notes about existing behavior
The menu is modified in memory when:

  • tab is closed (history menu rebuilt - serialization added w/ this PR taking 0 ms)
  • menu item goes from checked to unchecked (or similar)

@bbondy bbondy modified the milestones: 0.17.17 (Release Channel), 0.18.x (Release Channel) Jul 17, 2017
@bbondy
Copy link
Member

bbondy commented Jul 17, 2017

Could you post or link up an issue for this? Thanks.

- methods are stripped out (will no longer be serialized)
- with a few thousand bookmarks, the initial stringify/parse takes ~60ms and is never done again
- menu (if present) is now deleted when saving session

Fixes #10016

Some notes about existing behavior
The menu is modified in memory  when:
  - tab is closed (history menu rebuilt - serialization added w/ this PR taking 0 ms)
  - menu item goes from checked to unchecked (or similar)

Auditors: @bridiver, @bbondy
@bsclifton
Copy link
Member Author

@bbondy issue created! 😄 (and commit updated to use closing keyword)
#10016

@@ -602,7 +606,10 @@ const createMenu = (state) => {
})
}

appActions.setMenubarTemplate(Immutable.fromJS(template))
if (isWindows) {
const menuTemplate = JSON.parse(JSON.stringify(template))
Copy link
Member

Choose a reason for hiding this comment

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

I talked to Clifton, the handlers aren't actually used in app state and this is only called once.

@bbondy bbondy merged commit 316d86d into brave:master Jul 17, 2017
bsclifton pushed a commit that referenced this pull request Jul 17, 2017
Only store menu in appState on Windows
bsclifton pushed a commit that referenced this pull request Jul 17, 2017
Only store menu in appState on Windows
bsclifton pushed a commit that referenced this pull request Jul 17, 2017
Only store menu in appState on Windows
@bsclifton bsclifton deleted the menu-in-app-state branch July 24, 2017 19:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants