-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add ability to set WebView ExecutionMode property (addresses #4720) #12509
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR is having some issues with Issue12134.CookiesCorrectlyLoadWithMultipleWebViews()
at Xamarin.Forms.Controls.Issues.Issue12134.CookiesCorrectlyLoadWithMultipleWebViews() in D:\agent\1\s\Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Issue12134.cs:line 120
@PureWeen I'll take a look and see if I can figure out the test failure. |
c8530ec
to
7f21cc4
Compare
|
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4720.cs
Outdated
Show resolved
Hide resolved
/azp run |
No pipelines are associated with this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't quite get it to crash even when loading YouTube a bunch of times. I did notice that after awhile it would start to lag. For now I changed the UI Test to just use Microsoft and reload the page ever 200 Ms
Waiting 2 seconds and reloading it 10 times just makes this test a bit too slow. I also just converted this property over to a platform specific so users can opt into it if they want to from the xplat code opposed to a renderer
/azp run |
No pipelines are associated with this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, much cleaner to have the platform specific
/azp run |
No pipelines are associated with this pull request. |
…4720) (xamarin#12509) * To address issue xamarin#4720: Add option for custom renderers to control the execution mode of the WebView control This is 'opt-in' as by default this commit will not change behavior of existing applciations. to opt-in, people would need to set the ExecutionMode property in the constructor of their custom WebViewRenderer, like: public class MyWebViewRenderer : WebViewRenderer { public MyWebViewRenderer() { ExecutionMode = Windows.UI.Xaml.Controls.WebViewExecutionMode.SeparateProcess; } } When set as 'SeparateProcess', the memory allocated by the WebView itself is all handled in a sub-process, which ensures the main process never crashes from running out of memory here from doing things like opening and closing youtube every 5 seconds. This behavior will likely crash when the WebView is in-process due to the huge amounts of memory that is required by that website. * tabs not spaces * TemplatedItemsList: Ensure items are unhooked correctly when removing them, whether as individual removals or list resets. Without this, the native cells do not actually get removed. CellTableViewCell: use event PropertyChangedEventHandler instead of action (seems more standard) TextCellRenderer: Correct the event delegate hookup ListViewRenderer: Actually re-use the UITableViewCell when creating header sections, otherwise we endlessly create new ones, leaving the old ones alive through event handlers * Revert "TemplatedItemsList: Ensure items are unhooked correctly when removing them, whether as individual removals or list resets. Without this, the native cells do not actually get removed." This reverts commit 7da9ffb. * Make the custom renderer only apply to the test for this issue, as it seems the SeparateProcess affects access to cookies, breaking other tests * Move additional classes inside test class to decrease namespace cluttering. * - cleanup and rebase * - add instructions * - move WebViewExecutionMode to platform specific * - fix up UI Test * - clean up tests * - fix tabs * - fix formatting * - fix teardown call * - fix async ui test quirk on uwp Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Description of Change
Add platform specific to set the ExecutionMode on a WebView on UWP
When set as 'SeparateProcess', the memory allocated by the WebView itself is all handled in a sub-process, which ensures the main process never crashes from running out of memory here from doing things like opening and closing youtube every 5 seconds. This behavior will likely crash when the WebView is in-process due to the huge amounts of memory that is required by that website.
This change is related to issue #4720, however I do not believe that issue is actually a bug. This change does nothing to address a "memory leak" directly, and due to the addition of the new protected member, I wasn't sure if this is classed as an "API change" but thought it would be better to be on the safe side...
Issues Resolved
API Changes
Added:
Xamarin.Forms.Platform.UWP.WebViewRenderer
Changed:
None
Removed:
None
Platforms Affected
Behavioral/Visual Changes
None
Before/After Screenshots
Not applicable
Testing Procedure
Simply opening and closing a view that contains a WebView, pointed at something like youtube.com will cause huge memory usage which is not immediately reclaimed. When the WebView is running in SeparateProcess mode, there is a child process that is created that handles the memory itself (see ExecutionMode property
PR Checklist