Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: Dynamically updating HiddenPdfToolbarItems is unreliable #4818

Open
awolbach opened this issue Sep 18, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@awolbach
Copy link

What happened?

When our WinForms application needs to show a PDF to the user, it launches it in a different form than the main application form. It creates a Form object and adds a new WebView2 control to it, awaits EnsureCoreWebView2Async on that control, navigates it directly to a PDF URL, then calls Form.Show. Prior to navigation, in the NavigationStarting event, it conditionally sets the HiddenPdfToolbarItems property depending on whether the user should have access to these toolbar items and whether the PDF is being accessed from an internal or external domain.

What we've found is that whether the setting takes effect is unreliable. Sometimes the intended items are hidden in the PDF plugin's toolbar and sometimes they are not. The decision to use NavigationStarting comes from this remark on the CoreWebView2Settings reference page: "Changes to IsGeneralAutofillEnabled and IsPasswordAutosaveEnabled will take effect immediately, while other setting changes made after NavigationStarting event do not apply until the next top-level navigation", but we've found that if we move the assignment before the Navigate call entirely, we see the same behavior.

Repro:
WebView2HiddenPDFToolbarItems.zip

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

128.0.2739.79

SDK Version

1.0.2739.15

Framework

Winforms

Operating System

Windows 11

OS Version

10.0.22631

Repro steps

Using the attached repro, these steps reliably demonstrate the issue:

  1. Launch the application and let msn.com load
  2. With both checkboxes unchecked, click the "Show PDF In New Form" button
  3. See the window appear and the PDF plugin load with all toolbar items visible
  4. Close the new window
  5. Check both checkboxes to instruct the application to hide the save and print buttons on the next launch
  6. Click the "Show PDF In New Form" button
  7. See the window appear and the PDF plugin load with all toolbar items visible except hide and save
  8. Close the new window
  9. Uncheck both checkboxes
  10. Click the "Show PDF In New Form" button
  11. See the window appear and the PDF plugin load with hide and save toolbar items still hidden

But also, if you just change the states of the checkboxes and relaunch repeatedly, eventually you'll notice that the new settings were not respected (seems nondeterministic).

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@awolbach awolbach added the bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant