mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Added some thread asserts to the code and made ios_surface_ safe since (flutter/engine#12775)
* Added some thread asserts to the code and made ios_surface_ safe since its being written and read from different threads. * responded to chinmays feedback, added comment
This commit is contained in:
parent
0681026147
commit
32158d169e
@ -49,7 +49,10 @@ class PlatformViewIOS final : public PlatformView {
|
||||
|
||||
private:
|
||||
fml::WeakPtr<FlutterViewController> owner_controller_;
|
||||
std::unique_ptr<IOSSurface> ios_surface_;
|
||||
// Since the `ios_surface_` is created on the platform thread but
|
||||
// used on the GPU thread we need to protect it with a mutex.
|
||||
std::mutex ios_surface_mutex_;
|
||||
std::unique_ptr<IOSSurface> ios_surface_ FML_GUARDED_BY(ios_surface_mutex_);
|
||||
std::shared_ptr<IOSGLContext> gl_context_;
|
||||
PlatformMessageRouter platform_message_router_;
|
||||
std::unique_ptr<AccessibilityBridge> accessibility_bridge_;
|
||||
|
||||
@ -43,6 +43,8 @@ fml::WeakPtr<FlutterViewController> PlatformViewIOS::GetOwnerViewController() co
|
||||
}
|
||||
|
||||
void PlatformViewIOS::SetOwnerViewController(fml::WeakPtr<FlutterViewController> owner_controller) {
|
||||
FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());
|
||||
std::lock_guard<std::mutex> guard(ios_surface_mutex_);
|
||||
if (ios_surface_ || !owner_controller) {
|
||||
NotifyDestroyed();
|
||||
ios_surface_.reset();
|
||||
@ -92,6 +94,8 @@ void PlatformViewIOS::RegisterExternalTexture(int64_t texture_id,
|
||||
|
||||
// |PlatformView|
|
||||
std::unique_ptr<Surface> PlatformViewIOS::CreateRenderingSurface() {
|
||||
FML_DCHECK(task_runners_.GetGPUTaskRunner()->RunsTasksOnCurrentThread());
|
||||
std::lock_guard<std::mutex> guard(ios_surface_mutex_);
|
||||
if (!ios_surface_) {
|
||||
FML_DLOG(INFO) << "Could not CreateRenderingSurface, this PlatformViewIOS "
|
||||
"has no ViewController.";
|
||||
@ -102,6 +106,7 @@ std::unique_ptr<Surface> PlatformViewIOS::CreateRenderingSurface() {
|
||||
|
||||
// |PlatformView|
|
||||
sk_sp<GrContext> PlatformViewIOS::CreateResourceContext() const {
|
||||
FML_DCHECK(task_runners_.GetIOTaskRunner()->RunsTasksOnCurrentThread());
|
||||
if (!gl_context_ || !gl_context_->ResourceMakeCurrent()) {
|
||||
FML_DLOG(INFO) << "Could not make resource context current on IO thread. "
|
||||
"Async texture uploads will be disabled. On Simulators, "
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user