Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
71de21c7
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
71de21c7
编写于
1月 31, 2020
作者:
G
gaaclarke
提交者:
GitHub
1月 31, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Started coalescing updates to viewport metrics after foregrounding the app. (#16270)
上级
d6b75b7c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
1 deletion
+74
-1
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
...form/darwin/ios/framework/Source/FlutterViewController.mm
+74
-1
未找到文件。
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
浏览文件 @
71de21c7
...
...
@@ -27,6 +27,62 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics
NSNotificationName
const
FlutterViewControllerWillDealloc
=
@"FlutterViewControllerWillDealloc"
;
/// Class to coalesce calls for a period of time.
///
/// This is used to filter out the conflicting notifications that can get sent
/// in rapid succession when the app gets foregrounded.
@interface
FlutterCoalescer
:
NSObject
@property
(
nonatomic
,
assign
)
BOOL
isTriggered
;
@property
(
nonatomic
,
assign
)
BOOL
isCoalescing
;
@property
(
nonatomic
,
copy
)
dispatch_block_t
block
;
@end
@implementation
FlutterCoalescer
-
(
instancetype
)
initWithBlock
:(
dispatch_block_t
)
block
{
self
=
[
super
init
];
if
(
self
)
{
self
.
block
=
block
;
}
return
self
;
}
-
(
void
)
dealloc
{
[
_block
release
];
[
super
dealloc
];
}
-
(
void
)
trigger
{
if
(
_isCoalescing
)
{
_isTriggered
=
YES
;
}
else
{
_isTriggered
=
NO
;
if
(
_block
)
{
_block
();
}
}
}
-
(
void
)
coalesceForSeconds
:(
double
)
seconds
{
if
(
self
.
isCoalescing
||
!
self
.
block
)
{
return
;
}
self
.
isCoalescing
=
YES
;
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
seconds
*
NSEC_PER_SEC
),
dispatch_get_main_queue
(),
^
{
if
(
self
.
isTriggered
&&
self
.
block
)
{
self
.
block
();
}
self
.
isTriggered
=
NO
;
self
.
isCoalescing
=
NO
;
});
}
-
(
void
)
invalidate
{
self
.
block
=
nil
;
}
@end
// FlutterCoalescer
// This is left a FlutterBinaryMessenger privately for now to give people a chance to notice the
// change. Unfortunately unless you have Werror turned on, incompatible pointers as arguments are
// just a warning.
...
...
@@ -64,6 +120,9 @@ typedef enum UIAccessibilityContrast : NSInteger {
BOOL
_viewOpaque
;
BOOL
_engineNeedsLaunch
;
NSMutableSet
<
NSNumber
*>*
_ongoingTouches
;
// Coalescer that filters out superfluous keyboard notifications when the app
// is being foregrounded.
fml
::
scoped_nsobject
<
FlutterCoalescer
>
_updateViewportMetrics
;
}
@synthesize
displayingFlutterUI
=
_displayingFlutterUI
;
...
...
@@ -147,6 +206,11 @@ typedef enum UIAccessibilityContrast : NSInteger {
_statusBarStyle
=
UIStatusBarStyleDefault
;
[
self
setupNotificationCenterObservers
];
__block
FlutterViewController
*
blockSelf
=
self
;
_updateViewportMetrics
.
reset
([[
FlutterCoalescer
alloc
]
initWithBlock
:
^
{
[
blockSelf
updateViewportMetricsImplementation
];
}]);
}
-
(
FlutterEngine
*
)
engine
{
...
...
@@ -531,6 +595,7 @@ typedef enum UIAccessibilityContrast : NSInteger {
userInfo:
nil
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
[
_ongoingTouches
release
];
[
_updateViewportMetrics
invalidate
];
[
super
dealloc
];
}
...
...
@@ -557,6 +622,7 @@ typedef enum UIAccessibilityContrast : NSInteger {
-
(
void
)
applicationWillEnterForeground
:(
NSNotification
*
)
notification
{
TRACE_EVENT0
(
"flutter"
,
"applicationWillEnterForeground"
);
[
self
goToApplicationLifecycle
:
@"AppLifecycleState.inactive"
];
[
_updateViewportMetrics
coalesceForSeconds
:
0.5
];
}
// Make this transition only while this current view controller is visible.
...
...
@@ -741,6 +807,13 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
#pragma mark - Handle view resizing
-
(
void
)
updateViewportMetrics
{
[
_updateViewportMetrics
trigger
];
}
/// The direct implementation of updateViewportMetrics, it doesn't conform to
/// the coalescing logic when foregrounding the app. Most calls should be
/// directed to [updateViewportMetrics].
-
(
void
)
updateViewportMetricsImplementation
{
[
_engine
.
get
()
updateViewportMetrics
:
_viewportMetrics
];
}
...
...
@@ -764,7 +837,7 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
_viewportMetrics
.
physical_height
=
viewSize
.
height
*
scale
;
[
self
updateViewportPadding
];
[
self
updateViewportMetrics
];
[
self
updateViewportMetrics
Implementation
];
// This must run after updateViewportMetrics so that the surface creation tasks are queued after
// the viewport metrics update tasks.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录