Skip to content

Revert: [android]: prewarms shaders when the context is created - #196468

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-196069-1794513324
Nov 13, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-196069-1794513324

Conversation

@flutteractionsbot

Copy link
Copy Markdown
Contributor

Reverts: [android]: prewarms shaders when the context is created

Initiated by: @andywolff

Reason for reverting: broke android_hardware_smoke_opengles_instrumented_tests shard, seems to have introduced a deadlock on opengles #196453

Original PR Author: @gaaclarke

Reviewed By: @walley892

The original PR description is provided below:

This preemptively starts compiling shaders as soon as the Context is created instead of waiting for the surface to be created. This has been measured to reduce startup time for mokey by 160ms.

One gotcha is that on vulkan the pixel format is compiled into the shaders, getting it wrong is very wasteful. Today we only use r8g8b8a8, but in the future that may change when we support wide gamut. I've added a debug assert to make sure what we warm up is what we use, which i'm pretty sure will be correct.

See the linked issue for more info ( #195920 )

fixes #195920

before

after

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutteractionsbot
flutteractionsbot requested a review from a team as a code owner November 12, 2026 19:55
@flutteractionsbot
flutteractionsbot requested review from jesswrd and removed request for a team November 12, 2026 19:55
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the pipeline warm-up mechanism, including the WarmDefaultPipelines and CreateDefaultPipelines methods, from ContentContext and PlatformViewAndroid, along with their associated unit tests and mock classes. Feedback on the changes highlights a potential null pointer dereference in the refactored ContentContext constructor, where context_ is dereferenced in the initializer list before the null-safety check is executed.

Comment on lines +530 to +552
ContentContext::ContentContext(
std::shared_ptr<Context> context,
std::shared_ptr<TypographerContext> typographer_context,
std::shared_ptr<RenderTargetAllocator> render_target_allocator)
: context_(std::move(context)),
lazy_glyph_atlas_(
std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
pipelines_(new Pipelines()),
tessellator_(std::make_shared<Tessellator>(
context_->GetCapabilities()->Supports32BitPrimitiveIndices())),
render_target_cache_(render_target_allocator == nullptr
? std::make_shared<RenderTargetCache>(
context_->GetResourceAllocator())
: std::move(render_target_allocator)),
data_host_buffer_(HostBuffer::Create(
context_->GetResourceAllocator(),
context_->GetIdleWaiter(),
context_->GetCapabilities()->GetMinimumUniformAlignment(),
context_->GetSubmissionTracker())),
text_shadow_cache_(std::make_unique<TextShadowCache>()) {
if (!context_ || !context_->IsValid()) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The constructor of ContentContext checks if context_ is null or invalid at line 550. However, before this check is reached, several member variables (tessellator_, render_target_cache_, and data_host_buffer_) are initialized in the initializer list (lines 538-548) by dereferencing context_ (e.g., calling context_->GetCapabilities(), context_->GetResourceAllocator(), etc.). If context is indeed null, this will result in a null pointer dereference and crash before the safety check is executed.

To prevent this, these member variables should be initialized inside the constructor body after the null check.

ContentContext::ContentContext(
    std::shared_ptr<Context> context,
    std::shared_ptr<TypographerContext> typographer_context,
    std::shared_ptr<RenderTargetAllocator> render_target_allocator)
    : context_(std::move(context)),
      lazy_glyph_atlas_(
          std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
      pipelines_(new Pipelines()),
      text_shadow_cache_(std::make_unique<TextShadowCache>()) {
  if (!context_ || !context_->IsValid()) {
    return;
  }

  tessellator_ = std::make_shared<Tessellator>(
      context_->GetCapabilities()->Supports32BitPrimitiveIndices());
  render_target_cache = render_target_allocator == nullptr
                             ? std::make_shared<RenderTargetCache>(
                                   context_->GetResourceAllocator())
                             : std::move(render_target_allocator);
  data_host_buffer_ = HostBuffer::Create(
      context_->GetResourceAllocator(),
      context_->GetIdleWaiter(),
      context_->GetCapabilities()->GetMinimumUniformAlignment(),
      context_->GetSubmissionTracker());

@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests team-android Owned by Android platform team labels Nov 12, 2026
gaaclarke
gaaclarke previously approved these changes Nov 12, 2026
@andywolff andywolff added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 12, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 13, 2026
Merged via the queue into flutter:master with commit fe5b23e Nov 13, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
@flutteractionsbot
flutteractionsbot deleted the revert-196069-1794513324 branch November 13, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eagerly initializeAiksContext on the raster thread during Shell::Create instead of waiting until SurfaceView.surfaceCreated

3 participants