Closed Bug 1947324 Opened 10 months ago Closed 3 months ago

Taskbar windows (thumbnails/titles) lack context menu

Categories

(Core :: Widget: Win32, defect, P3)

Firefox 135
x86_64
Windows 10
defect

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox-esr140 --- wontfix
firefox135 --- wontfix
firefox136 --- wontfix
firefox137 --- wontfix
firefox138 --- wontfix
firefox143 --- wontfix
firefox144 --- wontfix
firefox145 --- fixed

People

(Reporter: jscher2000, Assigned: gstoll)

References

(Regressed 2 open bugs, Regression)

Details

(Keywords: perf-alert, regression)

Attachments

(7 files, 1 obsolete file)

Starting in Firefox 135, right-clicking a window thumbnail or window title displayed by hovering the button on the Windows Taskbar does not generate a context menu. Instead, the right-click functions like a left click.

According to a mozregression by SUMO user JC, the regression was caused by bug 1934040 (removes WS_SYSMENU for Mica titlebar).

https://support.mozilla.org/en-US/questions/1491135#answer-1711172

Set release status flags based on info from the regressing bug 1934040

:emilio, since you are the author of the regressor, bug 1934040, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

So this is indeed a regression from that bug. The good thing is that there's an easy workaround for that menu, which is either:

  • Using Alt+Space on the keyboard.
  • Enabling the native titlebar (right click -> customize toolbar -> titlebar checkbox).

The bad news is that I don't see a great way of making that work without regressing bug 1934040: When I trigger the right click, I don't see any message sent to our window to potentially handle it (unlike the Alt+Space case which gives us a SYSCOMMAND message).

Maybe there's another way to convince DWM not to paint the caption button? https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.titlebarheightoption?view=windows-app-sdk-1.6 has a "Collapsed" variant. But I have no idea how that is implemented under the hood...

Component: Shell Integration → Widget: Win32
Flags: needinfo?(emilio)
Product: Firefox → Core
Duplicate of this bug: 1950006
Severity: -- → S3
Priority: -- → P3
Duplicate of this bug: 1950688

This insta-crashes on the first call to the Interop... function.

Duplicate of this bug: 1970063
Assignee: nobody → gstoll
Status: NEW → ASSIGNED

I'm going to take another look at this. After chatting with :handyman, I think our best path forward is to:

The second point will be tricky, although we do use some WinRT functionality already (an example)

It would be better / less invasive / simpler to use the undocumented "collapsed" height. That seemed to work in my testing with a local application.

Either way, we will need to call MddBootstrapInitialize() before doing any of this stuff. I've been working on this, and it's not going great. (about to go on PTO so leaving some notes for myself here)

I've been trying to pull in this folder on GitHub which has the definition of MddBootstrapInitialize(). It depends on wil and is generally just a lot of code that I haven't gotten to even compile yet.

Perhaps instead of trying to include enough stuff to make these files compile, I should try to pull out the core function FirstTimeInitialization() and trim out everything except the essentials.

I certainly don't know the limitations of this but Microsoft.WindowsAppRuntime.Bootstrap.dll should be available -- I've got it at "C:\Windows\SystemApps\Microsoft.WindowsAppRuntime.CBS_8wekyb3d8bbwe\Microsoft.WindowsAppRuntime.Bootstrap.dll". dumpbin shows that it has the expected MddBootstrapInitialize* methods.

OK, I have this DLL too - the good news is that I am able to ::LoadLibrary() on it and ::LoadProcAddress() on MddBootstrapInitialize2(). In order for the call to succeed, though, I had to install a "real" Windows App SDK from here. I was missing the "Microsoft.WinAppRuntime.DDLM" package, among others, and this is the Dynamic Dependency Lifetime Manager which apparently keeps the package from being modified while an unpackaged app (Firefox in this case) is using it.

So I think to be able to use this we would have to package a Windows App SDK installer in the Firefox installer. Microsoft has instructions on how to do this but I'm not sure if this would be acceptable for us.

Another possibility is to make Firefox a self-contained app which would just put the dependencies next to firefox.exe on disk. This might be more acceptable.

Anyway, for now I'm going to press onward and see if I can get the functionality we want with the titlebar to actually work.

OK, I'm able to call these methods by including all those WinRT headers. If I used the "collapsed" height then the minimize/maximize/close buttons are not drawn at all - I assume there's some change I need to make to make Firefox draw these, :emilio?

Flags: needinfo?(emilio)

Can you elaborate / attach a screenshot? Firefox draws its own titlebar buttons by default, so unless you've made any CSS change it should keep drawing its own.

Flags: needinfo?(emilio) → needinfo?(gstoll)

Oh, thanks, I had picked up a CSS change I forgot about, and reverting that made it work. Sorry!

Flags: needinfo?(gstoll)

I'm going to explore the self-contained route more. If we do this we don't even have to call MddBootstrapInitialize() - the point of that is to make sure the package doesn't get updated while we're using it, but that isn't an issue if we're using our own version of it.

I have this almost entirely working. The one part that doesn't is that if browser.tabs.inTitlebar is 0 (so we get the "standard" Windows titlebar with no tabs in it), the minimize/maximize/close buttons don't show up. I'm setting AppWindowTitleBar.ExtendsContentIntoTitleBar to false in this case, but setting PreferredHeightOption to Standard returns an error (since, as the documentation notes, that property only applies if ExtendsContentIntoTitleBar is true.

I assume that we are suppressing these buttons some other way - do you happen to know what that is, and if I should be doing something else in nsWindow::SetCustomTitlebar()?

(let me know if it would help to share my change; it's in a stack of ~25 patches now but I can squash it down)

Flags: needinfo?(emilio)

Do they not show up only in the first window open? Or in all of them?

Sure, sharing the patch would help though most likely you just need to make sure that the WS_SYSMENU is set (undoing bits of the regressing bug). In particular the skeleton UI need to recover that bit as well.

If it's not that, please send me a GitHub / try / something else link and I can take a look?

Flags: needinfo?(emilio)

Hmm, it’s definitely on the first window, I’m not sure I tried others.

Here’s a non-squished patch, I’ll get you a better one when I’m at my computer in around 2 hours: https://treeherder.mozilla.org/jobs?repo=try&revision=f5f330d6c759fee32abb78d4c15c8049cae04e54

OK, here's a squished version: https://treeherder.mozilla.org/jobs?repo=try&revision=e6077d6b9c2c07fdf7a2b69c3824d6137256dd84

After some more testing, indeed the buttons don't show up only on the first window open; subsequent windows are fine. (even if they're open when I toggle the pref) So I think you're right that this is a problem with the skeleton UI, but my change has WS_SYSMENU added to kPreXULSkeletonUIWindowStyle, which I thought would be sufficient. I'll play around with that some more.

Weird, Spy++ shows that the window does have WS_SYSMENU. (and in fact has the exact same styles as a new window, which does have the titlebar correctly) And this problem only happens if I launch with browser.tabs.inTitlebar turned on and then turn it off.

If I disable the skeleton UI the problem goes away entirely. So the problem is definitely related to the skeleton UI, but it doesn't seem related to WS_SYSMENU.

I figured it out - the problem was this line which doesn't seem to be true anymore (we do seem to use the skeleton UI in both cases), and in any event doesn't seem necessary.

This downloads the installers for the various flavors of Windows App SDK
and extracts the needed DLLs from them.

This also copies the needed DLLs to the dist/bin directory so Firefox
will be able to load them at runtime.

This essentially reverts bug 1934040, as that attempted to deal with
the problem of the wrong titlebar height with Mica on by not setting the
WS_SYSMENU style. However, this caused problems like this bug, where
taskbar windows couldn't be right-clicked on.

Now we accomplish the same thing by calling into the Windows App SDK to
set ExtendsContentIntoTitleBar and PreferredHeightOption appropriately.
This is done in WindowsUIUtils::SetIsTitlebarCollapsed(); the rest of this
change is almost entirely the revert of bug 1934040.

See Also: → 1959751
Pushed by imoraru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4a2a50478740 https://hg.mozilla.org/integration/autoland/rev/2a5a2c2d19c3 Revert "Bug 1947324 part 3 - use WinRT/Windows App SDK instead of WS_SYSMENU to collapse titlebar r=emilio" for causing multiple failures.
Flags: needinfo?(gstoll)
Flags: needinfo?(gstoll)
Regressions: 1990154

(In reply to Iulian Moraru from comment #30)

Revert for causing multiple failures.

Perfherder has detected a build_metrics performance change from push cb3327fb6325e42c645d4c5349b8e5d6bd2dc406.

If you have any questions, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
2% installer size windows2012-64-shippable nightly 129,503,459.92 -> 127,334,899.42

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.

You can run all of these tests on try with ./mach try perf --alert 46873

The following documentation link provides more information about this command.

Keywords: perf-alert
Attachment #9514349 - Attachment is obsolete: true

As a result of using the Windows App SDK we load a few more DLLs now.
Note that the "::$ea" syntax refers to a file's extended attributes.

Now that we're using the Windows App SDK to remove the minimize/maximize/close
buttons from the toolbar, the Windows App SDK seems to associate its own
window proc with the window, so this assertion was failing. Unstacking it
in this way doesn't seem to cause any issues.

On certain test runs (most notably opt-talos-xperf), Firefox runs
without local login privileges. This causes the Windows App SDK to
fail calling DCompositionCreateDevice3() with ERROR_ACCESS_DENIED,
and the code assumes it is going to succeed so it proceeds to crash
deferencing null.

So detect this case and don't use the Windows App SDK. I don't expect
any users will run into this, so it's unfortunate that we have to check,
but we just do it once.

Attachment #9517524 - Attachment description: Bug 1947324 part 6 - avoid using Windows App SDK without local login privileges r=bobowen!,#win-reviewers → Bug 1947324 part 6 - avoid using Windows App SDK on opt-talos-xperf runs r=bobowen!,#win-reviewers
Pushed by gstoll@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d5f33314b3aa https://hg.mozilla.org/integration/autoland/rev/8413a6fa9a77 part 1 - "build" Windows App SDK on toolchain tasks r=glandium https://github.com/mozilla-firefox/firefox/commit/af6ce89b6983 https://hg.mozilla.org/integration/autoland/rev/e488b02f821c part 2 - make Windows Firefox builds depend on the Windows App SDK r=glandium https://github.com/mozilla-firefox/firefox/commit/2fe4ae073010 https://hg.mozilla.org/integration/autoland/rev/5f22dfcea973 part 3 - use WinRT/Windows App SDK instead of WS_SYSMENU to collapse titlebar r=emilio https://github.com/mozilla-firefox/firefox/commit/af539d638d26 https://hg.mozilla.org/integration/autoland/rev/0c055e29e718 part 4 - add a few DLLs to xperf allowlists r=perftest-reviewers,kshampur https://github.com/mozilla-firefox/firefox/commit/796486a95674 https://hg.mozilla.org/integration/autoland/rev/26ae4fd252cd part 5 - remove assert for unstacked window procs on Windows r=win-reviewers,handyman https://github.com/mozilla-firefox/firefox/commit/2374da507a9b https://hg.mozilla.org/integration/autoland/rev/53aa44de71d6 part 6 - avoid using Windows App SDK on opt-talos-xperf runs r=bobowen,perftest-reviewers,kshampur
Regressions: 1992783
See Also: → 1992822
Duplicate of this bug: 1959751
Regressions: 1993474
Regressions: 1993942
Regressions: 1994215
QA Whiteboard: [qa-triage-done-c146/b145]
Regressions: 1995838
See Also: → 1996961
Regressions: 2000475
See Also: → 2002990
Regressions: 2005922
Regressions: 1996961
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: