Don't abort if the qml WebContext is destroyed before any webviews that use it
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Oxide |
Fix Released
|
Critical
|
Chris Coulson |
Bug Description
Currently the qml WebContext owns its BrowserContext, and we assert that BrowserContext outlives all WebView's that are using it. This is unfortunate, as it's quite easy for a simple mistake in qml to trigger an application abort.
What we should probably do is:
- Make BrowserContext reference counted
- Keep a reference to it from the qml WebContext, and any WebView's that use it
- Make WebContextAdapter a Data object on BrowserContext (using base::SupportsU
- When the qml WebContext and associated WebContextAdapter is deleted, clear the Data object from BrowserContext
- When accessing WebView.context, retrieve this via the Data object on BrowserContext
- If the Data object doesn't exist, create a new qml WebContext, add its WebContextAdapter to BrowserContext and return this.
The last couple of points are important - if a qml WebContext goes out of scope and is deleted, but the underlying BrowserContext is still in use by some webviews, we still want a way to access the context via WebView.context. And for WebView's that share a context, the returned contexts must always be the same.
Of course, this is complicated by the fact that there are 2 BrowserContext's for every Qml WebContext, and the lifetime of those must be identical