Extensions desktop capture API provides creates screen capture Widget context with no parent / root window |
|||
Issue descriptionSee crash in issue 828626 . I've resolved that issue, but this still seems weird. When using the Screencastify extension the screen recording picker is spawned from an extension action button's web contents bubble. The flow starts here: https://cs.chromium.org/chromium/src/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc?l=96 It uses the top-level window's native window as a context: https://cs.chromium.org/chromium/src/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc?l=85 Then it initializes the widget: #2 0x7f0f321b1680 aura::client::ParentWindowWithContext() #3 0x7f0f31168dd2 views::NativeWidgetAura::InitNativeWidget() #4 0x7f0f31149588 views::Widget::Init() #5 0x7f0f311533f4 views::DialogDelegate::CreateDialogWidget() #6 0x560aff9ac59e DesktopMediaPickerDialogView::DesktopMediaPickerDialogView() 7 0x560aff9addca DesktopMediaPickerViews::Show() #8 0x560b002327f8 extensions::DesktopCaptureChooseDesktopMediaFunctionBase::Execute() #9 0x560b00231c19 extensions::DesktopCaptureChooseDesktopMediaFunction::RunAsync() However, that top-level window (on aura at least) doesn't have a root window. This triggers a fallback path in the widget placement code (which I broke when I introduced the crash). However, it seems like it should provide a Widget context with a valid root window. I dunno if this is an extension bubble problem, a screen capture UI problem, or something else. +a couple people as extension and capture owners, just FYI
,
Apr 4 2018
I do not work on Chromium anymore, Brave Yao is the new owner of the desktop capturer component.
,
Apr 5 2018
Both lines, https://cs.chromium.org/chromium/src/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc?l=85 and https://cs.chromium.org/chromium/src/chrome/browser/ui/views/chrome_views_delegate_chromeos.cc?l=81, are like that for many years. I notice that when desktop_capture added the GetTopLevelNativeWindow() calling, there is a DCHECK, DCHECK(params->parent || params->context || !params->child), in chrome_views_delegate.cc(late moved to chrome_views_delegate_chromeos.cc). Which may indicates that things worked before, e.g. top level window has root window, and something else was changed recently? Anyway, any recommendation on how to provide the context info, under current situation?
,
Apr 5 2018
I think what happened before was ChromeViewsDelegate saw params->context not-null, so it would pass the DCHECK, then did this: params->context = params->context->GetRootWindow(); so then params->context became null, which triggered a fallback code path: if (!params->context && !params->parent) params->context = ash::Shell::Get... The fallback was never meant to run -- we just kept it because it was hard to find all the places where the widget didn't have a good context and we didn't want to crash on Chromebooks in the field. Anyway, maybe it could grab the top-level browser window associated with the extension? My guess is that this is related to the bubble - like maybe the bubble is closing, or is detached from the main widget, or something.
,
Apr 5 2018
Before your change in https://chromium-review.googlesource.com/c/chromium/src/+/988732, the DCHECK is after "GetRootWindow()", as if (params->context) params->context = params->context->GetRootWindow(); DCHECK(params->parent || params->context || !params->child) << "Please provide a parent or context for this widget."; if (!params->parent && !params->context) params->context = ash::Shell::GetPrimaryRootWindow(); So does this part of code never be run under debug building? Not even unittests? Otherwise there may be other regression. Since all the related codes are so old, I need time to figure out all the details :(
,
Apr 6 2018
Ah, the DCHECK was after the call to GetRootWindow(). Interesting. Yes, I suspect this code never ran for any test. (Or rather, the function runs a lot in tests, just every other widget provides a valid params->parent or params->context.) The reason we added the fallback was that we were worried there might be individual widgets that didn't provide parent or context, and it was difficult to prove that we found them all. BTW, I don't think this is a very important bug. It's just weird behavior and I wanted to make sure it was written down somewhere, and make sure it wasn't a sign of a more serious problem.
,
Apr 6 2018
+ sergeyu@ for more insight |
|||
►
Sign in to add a comment |
|||
Comment 1 by rdevlin....@chromium.org
, Apr 4 2018Owner: zijiehe@chromium.org
Status: Assigned (was: Untriaged)