Commit c1cfab3d authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

BackForwardCache: Track presence of WebGL for bfcache metrics

WebGL uses GPU resources. If a page in the back forward cache uses
WebGL, the page would keep the resources on GPU and this might be
problematic for other pages as GPU resources are limited.

Another option would be to cause context lost, but this is still
controversial. Most websites don't prepare for context lost and
increasing possibility of context lost might break websites.

Bug: 981740
Change-Id: Ib04680d9be76258c220d2f0e385eb10a17de567d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697189Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676829}
parent f0516ae9
......@@ -61,8 +61,10 @@ enum class WebSchedulerTrackedFeature {
kIndexedDBConnection = 28,
kWebGL = 29,
// NB: This enum is used in a bitmask, so kMaxValue must be less than 64.
kMaxValue = kIndexedDBConnection
kMaxValue = kWebGL
};
static_assert(static_cast<uint32_t>(WebSchedulerTrackedFeature::kMaxValue) < 64,
......
......@@ -1002,7 +1002,11 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(
num_gl_errors_to_console_allowed_(kMaxGLErrorsAllowedToConsole),
context_type_(context_type),
program_completion_queries_(
base::MRUCache<WebGLProgram*, GLuint>::NO_AUTO_EVICT) {
base::MRUCache<WebGLProgram*, GLuint>::NO_AUTO_EVICT),
feature_handle_for_scheduler_(
host->GetTopExecutionContext()->GetScheduler()->RegisterFeature(
SchedulingPolicy::Feature::kWebGL,
{SchedulingPolicy::RecordMetricsForBackForwardCache()})) {
DCHECK(context_provider);
// TODO(http://crbug.com/876140) Make sure this is being created on a
......
......@@ -1757,6 +1757,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
static constexpr unsigned int kMaxProgramCompletionQueries = 128u;
base::MRUCache<WebGLProgram*, GLuint> program_completion_queries_;
FrameOrWorkerScheduler::SchedulingAffectingFeatureHandle
feature_handle_for_scheduler_;
DISALLOW_COPY_AND_ASSIGN(WebGLRenderingContextBase);
};
......
......@@ -18,6 +18,7 @@ bool SchedulingPolicy::IsFeatureSticky(SchedulingPolicy::Feature feature) {
case Feature::kHasScriptableFramesInMultipleTabs:
case Feature::kBroadcastChannel:
case Feature::kIndexedDBConnection:
case Feature::kWebGL:
return false;
case Feature::kMainResourceHasCacheControlNoStore:
case Feature::kMainResourceHasCacheControlNoCache:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment