Repository navigation
refactor: remove InspectableWebContentsViewMac in favor of the Views version - #44628
Conversation
|
@zcbenz Hi! Could you please take a look at these changes? |
erickzhao
left a comment
There was a problem hiding this comment.
API LGTM
should be a user-facing noop
itsananderson
left a comment
There was a problem hiding this comment.
API LGTM
Thanks for fixing those regressions so we can re-land this!
codebytere
left a comment
There was a problem hiding this comment.
Thanks for working to get this re-landed!
| Date: Tue, 29 Oct 2024 21:16:29 +0100 | ||
| Subject: fix: Put NSVisualEffectView before ViewsCompositorSuperview | ||
|
|
||
| Otherwise when using `vibrancy` in `BrowserWindow` NSVisualEffectView |
There was a problem hiding this comment.
What's the path forward for this patch? I'd like to try upstreaming it or discussing it in Chromium issues before potentially floating this patch indefinitely.
There was a problem hiding this comment.
Chromium does not use NSVisualEffectView and vibrancy in their codebase, so it is not needed for them, however I'll try to upstream this change.
There was a problem hiding this comment.
These patches can potentially be avoided if we swizzle the function sortSubviewsUsingFunction of BridgedContentView. We can override the implementation to sort as needed in Electron.
Take a look at how @gerhardberger was able to do this to override mouse hit behavior: https://github.com/gerhardberger/electron-drag-click/blob/5d6878e308d561c711f22027ba76dad48a8b8143/electron_drag_click.mm#L83-L97
There was a problem hiding this comment.
Personally I don't like that idea. My fix is dependent on the SubviewSorter implementation, it is just adding another special view with higher priority. If we use overriding implementation of sortSubviewsUsingFunction we need to copy SubviewSorter implementation and apply to that copy changes which patch introduces. It will be still dependent on the SubviewSorter implementation, but without patch we will not notice changes in the original method or we may miss using our version of SubviewSorter if Chromium starts using its original implementation somewhere else. It may end up with potentially hidden bug if everything luckily compiles, which could be revealed on the gclient sync phase due to conflict during patching. Additionally these overrides look like missing inheritance substituted with inelegant solution. However if you still prefer using method_setImplementation and keeping this change fully in the Electron I will replace this patch with method_setImplementation.
There was a problem hiding this comment.
There was a problem hiding this comment.
Chromium team is not responding, can we merge this PR with this patch? Or should I use method_setImplementation in order to move change outside of the patches (in my opinion this is a bad idea: #44628 (comment))
There was a problem hiding this comment.
ping
There was a problem hiding this comment.
This patch has been upstreamed to Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/6030552
There was a problem hiding this comment.
Nice work on upstreaming the patch 👍
Can you add the line below to the patch description so the Upgrades Working Group folks can know that it can be dropped once Chromium is updated?
Upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/6030552
|
|
||
| // Destroy the native window in next tick because the native code might be | ||
| // iterating all windows. | ||
| base::SingleThreadTaskRunner::GetCurrentDefault()->DeleteSoon( |
| If we don't set `is_headless_` to false then some child windows | ||
| e.g. autofill popups will be created in headless mode leading to | ||
| ui problems (like dissapearing popup during typing in html's | ||
| input list. |
There was a problem hiding this comment.
Same here - is this an issue upstream would ever face @CezaryKulakowski? Can it be upstreamed?
There was a problem hiding this comment.
Unfortunately, I doubt it can be upstreamed, because we are abusing Chromium Widget headless mode for enforcing painting it before we show the window (as it is stated in the original refactor commit):
// We initialize the window in headless mode to allow painting before it is
// shown, but we don't want the headless behavior of allowing the window to be
// placed unconstrained.
There was a problem hiding this comment.
Is this non upstreamable patch a blocker?
There was a problem hiding this comment.
ping
There was a problem hiding this comment.
I don't think this is a blocker, if you looked into it and it's not tenable to upstream, that's alright, but we wanted to at least consider it
|
@codebytere Could you please respond to my comments in the issues? |
|
ping |
|
@codebytere ping |
|
ping ping |
|
ping ping ping |
|
@michal-pichlinski-openfin Sorry, we're in the middle of a quiet period right now, so responses will be slow! If you wouldn't mind resolving the conflicts in |
|
ping |
|
would note that with this change in place the resizing experience is much, much smoother and more responsive on macOS compared to without it. |
|
ping |
|
@VerteDinde @codebytere ping |
|
ping ping |
|
ping ping ping @VerteDinde @codebytere |
|
ping ping ping ping |
| Date: Tue, 29 Oct 2024 21:16:29 +0100 | ||
| Subject: fix: Put NSVisualEffectView before ViewsCompositorSuperview | ||
|
|
||
| Otherwise when using `vibrancy` in `BrowserWindow` NSVisualEffectView |
There was a problem hiding this comment.
Nice work on upstreaming the patch 👍
Can you add the line below to the patch description so the Upgrades Working Group folks can know that it can be dropped once Chromium is updated?
Upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/6030552
samuelmaddock
left a comment
There was a problem hiding this comment.
I will run CI and try to pull down the build to test soon.
| - (void)onElectronNativeWindowClosed { | ||
| shell_ = nullptr; | ||
| } |
There was a problem hiding this comment.
I suspect the observer can be replaced by overriding NSWindow's close method.
- (void)close {
shell_ = nullptr;
[super close];
}There was a problem hiding this comment.
@michal-pichlinski-openfin I made a small refactor to address this 0a53552
There was a problem hiding this comment.
@samuelmaddock @michal-pichlinski-openfin We're seeing crash reports which I believe are related to this change. See #47679.
When closing a window, it looks like sometimes a function is called on shell_ which is set to nullptr here.
Any chance you could take a look? :)
samuelmaddock
left a comment
There was a problem hiding this comment.
I ran e pr download-dist 44628 and tested the build locally against the previous regression issues. Everything seems to be working as expected.
lgtm
88fd302 to
2b6d669
Compare
…version * cherry-pick: refactor: remove InspectableWebContentsViewMac in favor of the Views version (electron#41326) commit e67ab9a Confilcts not resolved, except removal of the files removed by the original commit. * resolved conflicts and build issues after cherry-pick * cherry-picked: fix: add method allowing to disable headless mode in native widget electron#42996 fixing electron#42995 * fix: displaying select popup in window created as fullscreen window `constrainFrameRect:toScreen:` is not being call for windows created with `fullscreen: true` therefore `headless` mode was not being removed and `RenderWidgetHostNSViewBridge::DisplayPopupMenu` ignored displaying popup. Issue could be fixed by placing additional removal of `headless` mode in the `toggleFullScreen:`, but `orderWindow:relativeTo:` is called both for a regular and a fullscreen window, therefore there will be a single place fixing both cases. Because `electron::NativeWindowMac` lifetime may be shorter than `ElectronNSWindow` on which macOS may execute `orderWindow:relativeTo:` we need to clear `shell_` when `NativeWindow` is being closed. Fixes electron#43010. * fix: Content visibility when using `vibrancy` We need to put `NSVisualEffectView` before `ViewsCompositorSuperview` otherwise when using `vibrancy` in `BrowserWindow` `NSVisualEffectView` will hide content displayed by the compositor. Fixes electron#43003 Fixes electron#42336 In fact main issues reported in these tickets were not present after cherry-picking original refactor switching to `views::WebView`, so text could be selected and click event was properly generated. However both issues testcases were using `vibrancy` and actual content was invisible, because it was covered by the `NSVisualEffectView`. * fix: EXCEPTION_ACCESS_VIOLATION crash on BrowserWindow.destroy() Restored postponed deletion of the `NativeWindow`. Restoration caused `DCHECK(new_parent_ui_layer->GetCompositor());` failure in `BrowserCompositorMac::SetParentUiLayer` after the spec test: `chrome extensions chrome.webRequest does not take precedence over Electron webRequest - http` with stack: ``` 7 Electron Framework 0x000000011fe07830 content::BrowserCompositorMac::SetParentUiLayer(ui::Layer*) + 628 8 Electron Framework 0x000000011fe0c154 content::RenderWidgetHostViewMac::SetParentUiLayer(ui::Layer*) + 220 9 Electron Framework 0x000000011fe226a8 content::WebContentsViewMac::CreateViewForWidget(content::RenderWidgetHost*) + 600 10 Electron Framework 0x000000011fd37e4c content::WebContentsImpl::CreateRenderWidgetHostViewForRenderManager(content::RenderViewHost*) + 164 11 Electron Framework 0x000000011fb32278 content::RenderFrameHostManager::CreateSpeculativeRenderFrame(content::SiteInstanceImpl*, bool, scoped_refptr<content::BrowsingContextState> const&) + 816 12 Electron Framework 0x000000011fb2ab8c content::RenderFrameHostManager::CreateSpeculativeRenderFrameHost(content::SiteInstanceImpl*, content::SiteInstanceImpl*, bool) + 1308 13 Electron Framework 0x000000011fb28598 content::RenderFrameHostManager::GetFrameHostForNavigation(content::NavigationRequest*, content::BrowsingContextGroupSwap*, std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>*) + 1796 14 Electron Framework 0x000000011fa78660 content::NavigationRequest::SelectFrameHostForOnRequestFailedInternal(bool, bool, std::__Cr::optional<std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>> const&) + 280 15 Electron Framework 0x000000011fa6a994 content::NavigationRequest::OnRequestFailedInternal(network::URLLoaderCompletionStatus const&, bool, std::__Cr::optional<std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>> const&, bo + 1008 16 Electron Framework 0x000000011fa7772c content::NavigationRequest::OnRequestFailed(network::URLLoaderCompletionStatus const&) + 72 17 Electron Framework 0x000000011f8554ac content::NavigationURLLoaderImpl::NotifyRequestFailed(network::URLLoaderCompletionStatus const&) + 248 ``` This was probably the reason of removing `NativeWindow` immediately in order to cleanup `views_host_` in `WebContentsViewMac` to prevent using layer without compositor in `WebContentsViewMac::CreateViewForWidget`. `[ElectronNSWindowDelegate windowWillClose:]` is deleting window host and the compositor used by the `NativeWindow` therefore detach `NativeWindow` contents from parent. This will clear `views_host_` and prevent failing mentioned `DCHECK`. Fixes electron#42975 * chore: Applied review suggestions
2b6d669 to
e2962bc
Compare
|
ping @codebytere Could you please resolve your change request? Or should change something more? |
|
No Release Notes |
|
I have automatically backported this PR to "35-x-y", please check out #45238 |
* chore: remove dump_syms.patch It patches generate_breakpad_symbols.py, which Electron has not invoked since #19042. * chore: remove crashpad_pid_check.patch Its removal condition (crashpad initialized before the sandbox) was met in #23265; what remained disabled is crashpad's client PID verification on Windows. * chore: remove disable_compositor_recycling.patch Since #44628 macOS uses the views WebContentsView with a parent ui::Compositor, so the recyclable-compositor path this targeted is not taken; its remaining effect was suppressing DelegatedFrameHost::WasHidden. * chore: remove chore_provide_iswebcontentscreationoverridden_with_full_params.patch Nothing overrides IsWebContentsCreationOverridden or CreateCustomWebContents since #52472. * chore: remove fix_select_the_first_menu_item_when_opened_via_keyboard.patch Upstream selects the first item for keyboard-opened menus on Windows since M133 (https://chromium-review.googlesource.com/c/chromium/src/+/5868220) behind PlatformStyle::kAutoSelectFirstMenuItemFromKeyboard. * chore: remove revert_remove_the_allowaggressivethrottlingwithwebsocket_feature.patch Nothing in Electron references the feature; backgroundThrottling: false and --disable-background-timer-throttling cover the use case. * chore: remove fix_fire_menu_popup_start_for_dynamically_created_aria_menus.patch Upstream fires the popup events for dynamically created menus since M150 (https://chromium-review.googlesource.com/c/chromium/src/+/7804599), and the hunk here was gated on a feature nothing enabled. * chore: remove build_disable_llvm_unroll-add-parallel-reductions_on_apple_targets.patch The miscompile was fixed by llvm/llvm-project#210957, which is in the bundled clang (llvmorg-24-init-3796). * chore: remove refactor_unfilter_unresponsive_events.patch web-contents.ts re-applied the same three conditions (not ignored, visible, renderer initialized) before emitting 'unresponsive', so the unfiltered notification was never observable. Let Chromium filter and emit directly. * chore: remove fix_disable_enable_resource_allowlist_generation_on_windows.patch The siso-incompatible link wrapper it worked around was reverted upstream (https://chromium-review.googlesource.com/c/chromium/src/+/8275653, in this Chromium), so set enable_resource_allowlist_generation from all.gn as intended. * chore: remove nan test_use_v8_version_check_instead_of_node_version_check.patch With Node 24 the upstream nodeVersion > 22 check already selects the same expectations, so the V8-version check changes nothing. * chore: remove nan fix_remove_deprecated_propertycallbackinfo_holder.patch V8 re-added PropertyCallbackInfo::Holder(), so nan's tests compile unchanged. * chore: remove reclient-configs fix_disable_compression_threshold.patch reproxy.cfg is not read under siso. * chore: remove reclient-configs build_on_windows_provide_clang_wrapper_as_toolchain_input.patch siso merges inputs and toolchain_inputs from the rewrapper cfg and passes the remote_wrapper itself, so the distinction no longer matters. * chore: remove reclient-configs fix_temporarily_use_toolchain_inputs_exclusively_instead_of_inputs.patch Same as the Windows one: a no-op under siso's merged input list, and the python cfgs it also touched have no consumer since Chromium dropped python remote actions. * chore: remove reclient-configs reland_mojo_use_large_worker_for_mojom_parser_action.patch The rewrapper_<os>_large.cfg consumer was removed upstream in https://chromium-review.googlesource.com/c/chromium/src/+/6325750. * chore: reduce fix_add_python_remote_wrapper.patch to the clang wrapper chmod Chromium removed python remote actions (https://chromium-review.googlesource.com/c/chromium/src/+/6289606), so the python wrapper and cfg hunks have no consumer; the exec bit on the generated clang_remote_wrapper is the part siso still relies on from macOS hosts. * chore: trim dead hunks from render_widget_host_view_mac.patch Nothing has implemented shouldIgnoreMouseEvent since #38404. * chore: trim dead hunks from desktop_media_list.patch The Update(callback, refresh_thumbnails) signature change is unused since #50960 moved DesktopCapturer to StartUpdating(). * chore: trim dead hunks from allow_in-process_windows_to_have_different_web_prefs.patch enable_websql has no reader (WebSQL is gone from Blink) and none of the added fields use base::FilePath, so drop the field and the three file_path includes/imports. * chore: trim dead hunks from chore_restore_some_deprecated_wrapper_utility_in_gin.patch gin::DeprecatedWrappable(Base), its Converter, internal::FromV8Impl and gin/wrapper_info.cc duplicate what shell/common/gin_helper already defines (including gin::DeprecatedWrapperInfo::From) and are not referenced; keep the DeprecatedWrapperInfo struct, the per-isolate template maps and the internal field setup that gin_helper relies on. * chore: trim dead hunks from refactor_expose_file_system_access_blocklist.patch Electron does not compile chrome_file_system_access_permission_context.cc, so the #if 0 blocks in it did nothing; keep the header refactor. * chore: trim dead hunks from feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch The show-hidden plumbing has had no caller since #51704 (showHiddenFiles is macOS/Windows only), and the portal file carried two unused includes, one of them into electron/. * chore: trim dead hunks from support_mixed_sandbox_with_zygote.patch The RendererSandboxedProcessLauncherDelegateWin hunk was guarded by USE_ZYGOTE, which is never set on Windows. * chore: trim dead hunks from chore_grandfather_in_electron_views_and_delegates.patch MenuBar and InspectableWebContentsView never construct the passkeys themselves (RootView and DevToolsWindowDelegate do it for them). * chore: trim dead hunks from web_contents.patch The RenderWidgetHostViewBase forward declaration was unused. * chore: trim dead hunks from boringssl feat_expose_several_extra_cipher_functions.patch cipher.h already declares EVP_aes_256_cfb128. * chore: trim dead hunks from the webrtc pipewire patch The capturer_failed_ assignment inside the if duplicated the unconditional one upstream added below it, and the description still listed two items that no longer correspond to any hunk; what remains is the X11 fallback, so name it that. * chore: update patches * chore: gn format build/args/all.gn * Revert "chore: remove refactor_unfilter_unresponsive_events.patch" This reverts commit 03a3bd1. * Revert "chore: remove revert_remove_the_allowaggressivethrottlingwithwebsocket_feature.patch" This reverts commit 9db932e. * Revert "chore: remove disable_compositor_recycling.patch" This reverts commit 9d53659. * chore: update patches * chore: make refactor_expose_file_system_access_blocklist.patch header-only The earlier trim restored the .cc from Chromium trunk rather than the pinned revision, which pulled unrelated upstream lines into the export. * Revert "chore: remove fix_select_the_first_menu_item_when_opened_via_keyboard.patch" This reverts commit 1fe5f4e. * chore: keep first-menu-item selection for keyboard-opened menus off Windows Upstream only auto-selects behind PlatformStyle::kAutoSelectFirstMenuItemFromKeyboard, which is Windows-only, so keep the patch for the other views platforms and skip it on Windows where upstream now handles it.
Description of Change
This is the re-land of #41326 with fixes for the issues which enforced revert of the refactor.
For ease of review first commit is a cherry-pick of original change e67ab9a without fixing conflicts and build issues. Second commit resolves these conflicts and fixes building Electron. Further commits are fixes for following issues which caused revert:
Fixes #42995
Fixes #43010
Fixes #43003
Fixes #42336
Fixes #42335
Fixes #42975
Checklist
npm testpassesRelease Notes
Notes: none