Repository navigation
Revert: [android]: prewarms shaders when the context is created - #196468
Conversation
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
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());…ter#196069)" This reverts commit b1ea363.
c52b234 to
8b6980b
Compare
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-assistbot 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.