diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index 07e62e5d4e8e1..9f920330b0fae 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -98,7 +98,7 @@ typedef CanvasPath Path; V(NativeStringAttribute::initSpellOutStringAttribute, 3) \ V(PlatformConfigurationNativeApi::DefaultRouteName, 0) \ V(PlatformConfigurationNativeApi::ScheduleFrame, 0) \ - V(PlatformConfigurationNativeApi::Render, 1) \ + V(PlatformConfigurationNativeApi::Render, 4) \ V(PlatformConfigurationNativeApi::UpdateSemantics, 1) \ V(PlatformConfigurationNativeApi::SetNeedsReportTimings, 1) \ V(PlatformConfigurationNativeApi::SetIsolateDebugName, 1) \ diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 19e8444d0bdd9..e47ae8d57a3ff 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -308,29 +308,6 @@ class PlatformDispatcher { _invoke(onMetricsChanged, _onMetricsChangedZone); } - // A debug-only variable that stores the [FlutterView]s for which - // [FlutterView.render] has already been called during the current - // [onBeginFrame]/[onDrawFrame] callback sequence. - // - // It is null outside the scope of those callbacks indicating that calls to - // [FlutterView.render] must be ignored. Furthermore, if a given [FlutterView] - // is already present in this set when its [FlutterView.render] is called - // again, that call must be ignored as a duplicate. - // - // Between [onBeginFrame] and [onDrawFrame] the properties value is - // temporarily stored in `_renderedViewsBetweenCallbacks` so that it survives - // the gap between the two callbacks. - // - // In release build, this variable is null, and therefore the calling rule is - // not enforced. This is because the check might hurt cold startup delay; - // see https://github.com/flutter/engine/pull/46919. - Set? _debugRenderedViews; - // A debug-only variable that temporarily stores the `_renderedViews` value - // between `_beginFrame` and `_drawFrame`. - // - // In release build, this variable is null. - Set? _debugRenderedViewsBetweenCallbacks; - /// A callback invoked when any view begins a frame. /// /// A callback that is invoked to notify the application that it is an @@ -351,26 +328,11 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _beginFrame(int microseconds) { - assert(_debugRenderedViews == null); - assert(_debugRenderedViewsBetweenCallbacks == null); - assert(() { - _debugRenderedViews = {}; - return true; - }()); - _invoke1( onBeginFrame, _onBeginFrameZone, Duration(microseconds: microseconds), ); - - assert(_debugRenderedViews != null); - assert(_debugRenderedViewsBetweenCallbacks == null); - assert(() { - _debugRenderedViewsBetweenCallbacks = _debugRenderedViews; - _debugRenderedViews = null; - return true; - }()); } /// A callback that is invoked for each frame after [onBeginFrame] has @@ -388,22 +350,7 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _drawFrame() { - assert(_debugRenderedViews == null); - assert(_debugRenderedViewsBetweenCallbacks != null); - assert(() { - _debugRenderedViews = _debugRenderedViewsBetweenCallbacks; - _debugRenderedViewsBetweenCallbacks = null; - return true; - }()); - _invoke(onDrawFrame, _onDrawFrameZone); - - assert(_debugRenderedViews != null); - assert(_debugRenderedViewsBetweenCallbacks == null); - assert(() { - _debugRenderedViews = null; - return true; - }()); } /// A callback that is invoked when pointer data is available. diff --git a/lib/ui/window.dart b/lib/ui/window.dart index 9475dc10ab2c9..98533d2fe3451 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -372,22 +372,11 @@ class FlutterView { /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. void render(Scene scene, {Size? size}) { - // Duplicated calls or calls outside of onBeginFrame/onDrawFrame (indicated - // by _debugRenderedViews being null) are ignored. See _debugRenderedViews. - // TODO(dkwingsmt): We should change this skip into an assertion. - // https://github.com/flutter/flutter/issues/137073 - bool validRender = true; - assert(() { - validRender = platformDispatcher._debugRenderedViews?.add(this) ?? false; - return true; - }()); - if (validRender) { - _render(scene as _NativeScene, size?.width ?? physicalSize.width, size?.height ?? physicalSize.height); - } + _render(viewId, scene as _NativeScene, size?.width ?? physicalSize.width, size?.height ?? physicalSize.height); } - @Native, Double, Double)>(symbol: 'PlatformConfigurationNativeApi::Render') - external static void _render(_NativeScene scene, double width, double height); + @Native, Double, Double)>(symbol: 'PlatformConfigurationNativeApi::Render') + external static void _render(int viewId, _NativeScene scene, double width, double height); /// Change the retained semantics data about this [FlutterView]. /// diff --git a/lib/ui/window/platform_configuration.cc b/lib/ui/window/platform_configuration.cc index b9fe4e73ba8d7..3ecadac12fe6f 100644 --- a/lib/ui/window/platform_configuration.cc +++ b/lib/ui/window/platform_configuration.cc @@ -449,9 +449,13 @@ void PlatformConfiguration::CompletePlatformMessageResponse( response->Complete(std::make_unique(std::move(data))); } -void PlatformConfigurationNativeApi::Render(Scene* scene, +void PlatformConfigurationNativeApi::Render(int64_t view_id, + Scene* scene, double width, double height) { + // TODO(dkwingsmt): Currently only supports a single window. + // See https://github.com/flutter/flutter/issues/135530, item 2. + FML_DCHECK(view_id == kFlutterImplicitViewId); UIDartState::ThrowIfUIOperationsProhibited(); UIDartState::Current()->platform_configuration()->client()->Render( scene, width, height); diff --git a/lib/ui/window/platform_configuration.h b/lib/ui/window/platform_configuration.h index 5b2940952a6d8..5f21051110472 100644 --- a/lib/ui/window/platform_configuration.h +++ b/lib/ui/window/platform_configuration.h @@ -557,7 +557,10 @@ class PlatformConfigurationNativeApi { static void ScheduleFrame(); - static void Render(Scene* scene, double width, double height); + static void Render(int64_t view_id, + Scene* scene, + double width, + double height); static void UpdateSemantics(SemanticsUpdate* update);