Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
8ebb3184
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
8ebb3184
编写于
11月 06, 2019
作者:
C
chunhtai
提交者:
GitHub
11月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Issues/39832 reland (#13642)" (#13720)
This reverts commit
1bfb928e
.
上级
d59b1583
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
29 addition
and
111 deletion
+29
-111
lib/ui/window.dart
lib/ui/window.dart
+9
-7
lib/web_ui/lib/src/ui/window.dart
lib/web_ui/lib/src/ui/window.dart
+9
-4
runtime/runtime_controller.h
runtime/runtime_controller.h
+1
-1
shell/common/engine.cc
shell/common/engine.cc
+1
-1
shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
...embedding/android/FlutterActivityAndFragmentDelegate.java
+0
-2
shell/platform/android/io/flutter/embedding/engine/systemchannels/LifecycleChannel.java
...ter/embedding/engine/systemchannels/LifecycleChannel.java
+0
-4
shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java
...dding/android/FlutterActivityAndFragmentDelegateTest.java
+0
-11
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+9
-15
testing/scenario_app/ios/Scenarios/ScenariosTests/AppLifecycleTests.m
...ario_app/ios/Scenarios/ScenariosTests/AppLifecycleTests.m
+0
-66
未找到文件。
lib/ui/window.dart
浏览文件 @
8ebb3184
...
...
@@ -171,16 +171,18 @@ enum AppLifecycleState {
///
/// When the application is in this state, the engine will not call the
/// [Window.onBeginFrame] and [Window.onDrawFrame] callbacks.
///
/// Android apps in this state should assume that they may enter the
/// [suspending] state at any time.
paused
,
/// The application is still hosted on a flutter engine but is detached from
/// any host views.
/// The application will be suspended momentarily.
///
/// When the application is in this state, the engine will not call the
/// [Window.onBeginFrame] and [Window.onDrawFrame] callbacks.
///
/// When the application is in this state, the engine is running without
/// a view. It can either be in the progress of attaching a view when engine
/// was first initializes, or after the view being destroyed due to a Navigator
/// pop.
detached
,
/// On iOS, this state is currently unused.
suspending
,
}
/// A representation of distances for each of the four edges of a rectangle,
...
...
lib/web_ui/lib/src/ui/window.dart
浏览文件 @
8ebb3184
...
...
@@ -73,13 +73,18 @@ enum AppLifecycleState {
///
/// When the application is in this state, the engine will not call the
/// [Window.onBeginFrame] and [Window.onDrawFrame] callbacks.
///
/// Android apps in this state should assume that they may enter the
/// [suspending] state at any time.
paused
,
/// The application is detached from view.
/// The application will be suspended momentarily.
///
/// When the application is in this state, the engine will not call the
/// [Window.onBeginFrame] and [Window.onDrawFrame] callbacks.
///
/// When the application is in this state, the engine is running without
/// a platform UI.
detached
,
/// On iOS, this state is currently unused.
suspending
,
}
/// A representation of distances for each of the four edges of a rectangle,
...
...
runtime/runtime_controller.h
浏览文件 @
8ebb3184
...
...
@@ -120,7 +120,7 @@ class RuntimeController final : public WindowClient {
std
::
string
variant_code
;
std
::
vector
<
std
::
string
>
locale_data
;
std
::
string
user_settings_data
=
"{}"
;
std
::
string
lifecycle_state
=
"AppLifecycleState.detached"
;
std
::
string
lifecycle_state
;
bool
semantics_enabled
=
false
;
bool
assistive_technology_enabled
=
false
;
int32_t
accessibility_feature_flags_
=
0
;
...
...
shell/common/engine.cc
浏览文件 @
8ebb3184
...
...
@@ -311,7 +311,7 @@ bool Engine::HandleLifecyclePlatformMessage(PlatformMessage* message) {
const
auto
&
data
=
message
->
data
();
std
::
string
state
(
reinterpret_cast
<
const
char
*>
(
data
.
data
()),
data
.
size
());
if
(
state
==
"AppLifecycleState.paused"
||
state
==
"AppLifecycleState.
detached
"
)
{
state
==
"AppLifecycleState.
suspending
"
)
{
activity_running_
=
false
;
StopAnimator
();
}
else
if
(
state
==
"AppLifecycleState.resumed"
||
...
...
shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
浏览文件 @
8ebb3184
...
...
@@ -461,8 +461,6 @@ import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;
platformPlugin
=
null
;
}
flutterEngine
.
getLifecycleChannel
().
appIsDetached
();
// Destroy our FlutterEngine if we're not set to retain it.
if
(
host
.
shouldDestroyEngineWithHost
())
{
flutterEngine
.
destroy
();
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/LifecycleChannel.java
浏览文件 @
8ebb3184
...
...
@@ -39,8 +39,4 @@ public class LifecycleChannel {
channel
.
send
(
"AppLifecycleState.paused"
);
}
public
void
appIsDetached
()
{
Log
.
v
(
TAG
,
"Sending AppLifecycleState.detached message."
);
channel
.
send
(
"AppLifecycleState.detached"
);
}
}
shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java
浏览文件 @
8ebb3184
...
...
@@ -85,21 +85,18 @@ public class FlutterActivityAndFragmentDelegateTest {
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsResumed
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsPaused
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsInactive
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsDetached
();
// When the Activity/Fragment is resumed, a resumed message should have been sent to Flutter.
delegate
.
onResume
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsResumed
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsInactive
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsPaused
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsDetached
();
// When the Activity/Fragment is paused, an inactive message should have been sent to Flutter.
delegate
.
onPause
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsResumed
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsInactive
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsPaused
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsDetached
();
// When the Activity/Fragment is stopped, a paused message should have been sent to Flutter.
// Notice that Flutter uses the term "paused" in a different way, and at a different time
...
...
@@ -108,14 +105,6 @@ public class FlutterActivityAndFragmentDelegateTest {
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsResumed
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsInactive
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsPaused
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
never
()).
appIsDetached
();
// When activity detaches, a detached message should have been sent to Flutter.
delegate
.
onDetach
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsResumed
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsInactive
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsPaused
();
verify
(
mockFlutterEngine
.
getLifecycleChannel
(),
times
(
1
)).
appIsDetached
();
}
@Test
...
...
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
浏览文件 @
8ebb3184
...
...
@@ -175,23 +175,18 @@ NSString* const FlutterDefaultDartEntrypoint = nil;
-
(
void
)
setViewController
:(
FlutterViewController
*
)
viewController
{
FML_DCHECK
(
self
.
iosPlatformView
);
_viewController
=
viewController
?
[
viewController
getWeakPtr
]
:
fml
::
WeakPtr
<
FlutterViewController
>
();
_viewController
=
[
viewController
getWeakPtr
];
self
.
iosPlatformView
->
SetOwnerViewController
(
_viewController
);
[
self
maybeSetupPlatformViewChannels
];
if
(
viewController
)
{
__block
FlutterEngine
*
blockSelf
=
self
;
self
.
flutterViewControllerWillDeallocObserver
=
[[
NSNotificationCenter
defaultCenter
]
addObserverForName
:
FlutterViewControllerWillDealloc
object:
viewController
queue:
[
NSOperationQueue
mainQueue
]
usingBlock:
^
(
NSNotification
*
note
)
{
[
blockSelf
notifyViewControllerDeallocated
];
}];
}
else
{
self
.
flutterViewControllerWillDeallocObserver
=
nil
;
}
__block
FlutterEngine
*
blockSelf
=
self
;
self
.
flutterViewControllerWillDeallocObserver
=
[[
NSNotificationCenter
defaultCenter
]
addObserverForName
:
FlutterViewControllerWillDealloc
object:
viewController
queue:
[
NSOperationQueue
mainQueue
]
usingBlock:
^
(
NSNotification
*
note
)
{
[
blockSelf
notifyViewControllerDeallocated
];
}];
}
-
(
void
)
setFlutterViewControllerWillDeallocObserver
:(
id
<
NSObject
>
)
observer
{
...
...
@@ -206,7 +201,6 @@ NSString* const FlutterDefaultDartEntrypoint = nil;
}
-
(
void
)
notifyViewControllerDeallocated
{
[[
self
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.detached"
];
if
(
!
_allowHeadlessExecution
)
{
[
self
destroyContext
];
}
else
{
...
...
testing/scenario_app/ios/Scenarios/ScenariosTests/AppLifecycleTests.m
浏览文件 @
8ebb3184
...
...
@@ -225,70 +225,4 @@
[
engine
setViewController
:
nil
];
}
-
(
void
)
testFlutterViewControllerDetachingSendsApplicationLifecycle
{
XCTestExpectation
*
engineStartedExpectation
=
[
self
expectationWithDescription
:
@"Engine started"
];
// Let the engine finish booting (at the end of which the channels are properly set-up) before
// moving onto the next step of showing the next view controller.
ScreenBeforeFlutter
*
rootVC
=
[[
ScreenBeforeFlutter
alloc
]
initWithEngineRunCompletion
:
^
void
()
{
[
engineStartedExpectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
5
handler
:
nil
];
UIApplication
*
application
=
UIApplication
.
sharedApplication
;
application
.
delegate
.
window
.
rootViewController
=
rootVC
;
FlutterEngine
*
engine
=
rootVC
.
engine
;
NSMutableArray
*
lifecycleExpectations
=
[
NSMutableArray
arrayWithCapacity
:
10
];
// Expected sequence from showing the FlutterViewController is inactive and resumed.
[
lifecycleExpectations
addObjectsFromArray
:@[
[[
XCAppLifecycleTestExpectation
alloc
]
initForLifecycle
:
@"AppLifecycleState.inactive"
forStep:
@"showing a FlutterViewController"
],
[[
XCAppLifecycleTestExpectation
alloc
]
initForLifecycle
:
@"AppLifecycleState.resumed"
forStep:
@"showing a FlutterViewController"
]
]];
// At the end of Flutter VC, we want to make sure it deallocs and sends detached signal.
// Using autoreleasepool will guarantee that.
FlutterViewController
*
flutterVC
;
@autoreleasepool
{
flutterVC
=
[
rootVC
showFlutter
];
[
engine
.
lifecycleChannel
setMessageHandler
:
^
(
id
message
,
FlutterReply
callback
)
{
if
(
lifecycleExpectations
.
count
==
0
)
{
XCTFail
(
@"Unexpected lifecycle transition: %@"
,
message
);
return
;
}
XCAppLifecycleTestExpectation
*
nextExpectation
=
[
lifecycleExpectations
objectAtIndex
:
0
];
if
(
!
[[
nextExpectation
expectedLifecycle
]
isEqualToString
:
message
])
{
XCTFail
(
@"Expected lifecycle %@ but instead received %@"
,
[
nextExpectation
expectedLifecycle
],
message
);
return
;
}
[
nextExpectation
fulfill
];
[
lifecycleExpectations
removeObjectAtIndex
:
0
];
}];
[
self
waitForExpectations
:
lifecycleExpectations
timeout
:
5
];
// Starts dealloc flutter VC.
[
lifecycleExpectations
addObjectsFromArray
:@[
[[
XCAppLifecycleTestExpectation
alloc
]
initForLifecycle
:
@"AppLifecycleState.inactive"
forStep:
@"detaching a FlutterViewController"
],
[[
XCAppLifecycleTestExpectation
alloc
]
initForLifecycle
:
@"AppLifecycleState.paused"
forStep:
@"detaching a FlutterViewController"
],
[[
XCAppLifecycleTestExpectation
alloc
]
initForLifecycle:
@"AppLifecycleState.detached"
forStep:
@"detaching a FlutterViewController"
]
]];
[
flutterVC
dismissViewControllerAnimated
:
NO
completion
:
nil
];
flutterVC
=
nil
;
}
[
self
waitForExpectations
:
lifecycleExpectations
timeout
:
5
];
[
engine
.
lifecycleChannel
setMessageHandler
:
nil
];
[
engine
setViewController
:
nil
];
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录