Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Add an Info.plist flag to enable MacOS platform views preview support #22929

Conversation

RichardJCai
Copy link
Contributor

Enabling the flag io.flutter_embedded_views_preview enables platform view support for MacOS.

Additionally, when the flag is enabled, the render and main threads are merged, however this disables smooth resizing as smooth resizing requires synchronization and blocking between the main and render thread.

Tentatively using the io.flutter_embedded_views_preview flag as it was used in #6756.

Please only review the last commit, this PR depends on #22905 being merged.

@RichardJCai RichardJCai changed the title Add an Info.plist flag to enable MacOS platform views preview. Add an Info.plist flag to enable MacOS platform views preview support Dec 8, 2020
@RichardJCai RichardJCai force-pushed the macos_experimental_pv_static_thread_merging branch from 80af14c to b28f61f Compare December 8, 2020 20:07
…upport for MacOS.

Enabling the key disables smooth resizing.
@RichardJCai RichardJCai force-pushed the macos_experimental_pv_static_thread_merging branch from b28f61f to b33da83 Compare December 8, 2020 20:42
Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

I'm not sure about [FlutterView present] and [FlutterView reshaped]
Maybe @iskakaushik has more context as he reviewed #21525?

cc @knopp

#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController_Internal.h"

@implementation FlutterPlatformViewController
@implementation FlutterPlatformViewController {
bool _embeddedViewsEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this instance method.

// found in the LICENSE file.

// The name of the Info.plist flag to enable the embedded MacOS views preview.
const char* const kEmbeddedViewsPreview = "io.flutter_embedded_views_preview";
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need the constant in a separate file, can move it to FlutterPlatformViewController.mm

@@ -56,6 +71,11 @@ - (void)onDisposeWithViewId:(int64_t)viewId result:(nonnull FlutterResult)result

- (void)registerViewFactory:(nonnull NSObject<FlutterPlatformViewFactory>*)factory
withId:(nonnull NSString*)factoryId {
if (!_embeddedViewsEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just be if (![self embeddedViewsEnabled])

return self;
}

- (void)onCreateWithViewId:(int64_t)viewId
viewType:(nonnull NSString*)viewType
result:(nonnull FlutterResult)result {
if (!_embeddedViewsEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this, the if (factory == nil) already handles this.
Same in onDispose

@@ -15,6 +16,7 @@ @interface FlutterView () <FlutterResizeSynchronizerDelegate> {
__weak id<FlutterViewReshapeListener> _reshapeListener;
FlutterResizeSynchronizer* _resizeSynchronizer;
FlutterSurfaceManager* _surfaceManager;
bool _embedded_views_preview_enabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this ivar, can just use [FlutterPlatformViewController embeddedViewsEnabled] when necessary.

Copy link
Member

Choose a reason for hiding this comment

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

ivars should be camelCase.

@knopp
Copy link
Member

knopp commented Dec 8, 2020

First iteration of smooth resizing worked with merged platform / raster threads so it should be possible to do it here as well. I'll look into it when this lands. Might be bit trickier for dynamic thread merging.

@chinmaygarde
Copy link
Member

@iskakaushik Do you know who the owner for this is?

@RichardJCai
Copy link
Contributor Author

@iskakaushik Do you know who the owner for this is?

I'd be happy to continue working on this one, but waiting on this #22905 to get reviewed.

@chinmaygarde chinmaygarde added the Work in progress (WIP) Not ready (yet) for review! label Jan 14, 2021
@RichardJCai RichardJCai closed this Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Work in progress (WIP) Not ready (yet) for review!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants