diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-04-24 17:01:25 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:55:02 +0200 |
commit | 0b632445a933644c7eb10015eb04b7c21d562900 (patch) | |
tree | 5bd1fe200cc747086220dbcba90097bfe2cc4cdc /packages/shared/src/schemas/ServiceAction.ts | |
parent | chore(deps): upgrade dependencies (diff) | |
download | sophie-0b632445a933644c7eb10015eb04b7c21d562900.tar.gz sophie-0b632445a933644c7eb10015eb04b7c21d562900.tar.zst sophie-0b632445a933644c7eb10015eb04b7c21d562900.zip |
refactor: reduce service switcher tearing
We render the location bar and notification banners separately for each
service and keep track of the BrowserView size separately for each
service to reduce the tearing that appears when people switch services.
The tearing cannot be eliminated completely, because it comes from the
separation between the main and renderer processes. But we can at least
try and reduce the IPC round-tripping and layout calculations required
to accurately position the services.
This approach has an overhead compared to the single
BrowserViewPlaceholder approach, because the renderer process has to
layout the location bar and notification for all services, not only the
selected one. The number of IPC messages during windows resize is also
increased. To compensate, we increase the throttle interval for resize
IPC messages and let electron itself resize the BrowserView between IPC
updates. (We must still keep pumping IPC messages during window resize,
because, e.g., changes in notification banner size due to re-layouting
will still affect the required BrowserView size).
If further reduction of IPC traffic is needed, we could implement
batching for resize IPC messages and more intelligent throttling via a
token bucker mechanism.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/shared/src/schemas/ServiceAction.ts')
-rw-r--r-- | packages/shared/src/schemas/ServiceAction.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/shared/src/schemas/ServiceAction.ts b/packages/shared/src/schemas/ServiceAction.ts index c0f07d6..9486aaf 100644 --- a/packages/shared/src/schemas/ServiceAction.ts +++ b/packages/shared/src/schemas/ServiceAction.ts | |||
@@ -20,9 +20,15 @@ | |||
20 | 20 | ||
21 | import { z } from 'zod'; | 21 | import { z } from 'zod'; |
22 | 22 | ||
23 | import { BrowserViewBounds } from './BrowserViewBounds'; | ||
24 | |||
23 | export const ServiceAction = /* @__PURE__ */ (() => | 25 | export const ServiceAction = /* @__PURE__ */ (() => |
24 | z.union([ | 26 | z.union([ |
25 | z.object({ | 27 | z.object({ |
28 | action: z.literal('set-browser-view-bounds'), | ||
29 | browserViewBounds: BrowserViewBounds, | ||
30 | }), | ||
31 | z.object({ | ||
26 | action: z.literal('back'), | 32 | action: z.literal('back'), |
27 | }), | 33 | }), |
28 | z.object({ | 34 | z.object({ |