Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
eab9b7f2
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,发现更多精彩内容 >>
未验证
提交
eab9b7f2
编写于
7月 08, 2020
作者:
D
Dan Field
提交者:
GitHub
7月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call Dart_NotifyLowMemory more on iOS (#19289)
上级
0dc86cda
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
137 addition
and
4 deletion
+137
-4
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+1
-0
shell/platform/darwin/ios/BUILD.gn
shell/platform/darwin/ios/BUILD.gn
+1
-0
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+18
-4
shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm
...win/ios/framework/Source/FlutterEnginePlatformViewTest.mm
+96
-0
shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h
...form/darwin/ios/framework/Source/FlutterEngine_Internal.h
+2
-0
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
...form/darwin/ios/framework/Source/FlutterViewController.mm
+1
-0
shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
.../darwin/ios/framework/Source/FlutterViewControllerTest.mm
+18
-0
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
eab9b7f2
...
...
@@ -898,6 +898,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbac
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterHeadlessDartRunner.mm
...
...
shell/platform/darwin/ios/BUILD.gn
浏览文件 @
eab9b7f2
...
...
@@ -167,6 +167,7 @@ source_set("ios_test_flutter_mrc") {
"-mios-simulator-version-min=$ios_testing_deployment_target",
]
sources = [
"framework/Source/FlutterEnginePlatformViewTest.mm",
"framework/Source/accessibility_bridge_test.mm",
]
deps = [
...
...
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
浏览文件 @
eab9b7f2
...
...
@@ -117,6 +117,11 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
name:
UIApplicationDidReceiveMemoryWarningNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
applicationDidEnterBackground
:)
name:
UIApplicationDidEnterBackgroundNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
applicationBecameActive
:)
name:
UIApplicationDidBecomeActiveNotification
...
...
@@ -232,6 +237,7 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
}];
}
else
{
self
.
flutterViewControllerWillDeallocObserver
=
nil
;
[
self
notifyLowMemory
];
}
}
...
...
@@ -558,6 +564,13 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
return
[
self
runWithEntrypoint
:
entrypoint
libraryURI
:
nil
];
}
-
(
void
)
notifyLowMemory
{
if
(
_shell
)
{
_shell
->
NotifyLowMemoryWarning
();
}
[
_systemChannel
sendMessage
:@{
@"type"
:
@"memoryPressure"
}];
}
#pragma mark - Text input delegate
-
(
void
)
updateEditingClient
:(
int
)
client
withState
:(
NSDictionary
*
)
state
{
...
...
@@ -748,11 +761,12 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
[
self
setIsGpuDisabled
:
YES
];
}
-
(
void
)
applicationDidEnterBackground
:(
NSNotification
*
)
notification
{
[
self
notifyLowMemory
];
}
-
(
void
)
onMemoryWarning
:(
NSNotification
*
)
notification
{
if
(
_shell
)
{
_shell
->
NotifyLowMemoryWarning
();
}
[
_systemChannel
sendMessage
:@{
@"type"
:
@"memoryPressure"
}];
[
self
notifyLowMemory
];
}
-
(
void
)
setIsGpuDisabled
:(
BOOL
)
value
{
...
...
shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm
0 → 100644
浏览文件 @
eab9b7f2
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#define FML_USED_ON_EMBEDDER
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#import "flutter/fml/message_loop.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
FLUTTER_ASSERT_NOT_ARC
namespace
flutter
{
namespace
{
class
MockDelegate
:
public
PlatformView
::
Delegate
{
void
OnPlatformViewCreated
(
std
::
unique_ptr
<
Surface
>
surface
)
override
{}
void
OnPlatformViewDestroyed
()
override
{}
void
OnPlatformViewSetNextFrameCallback
(
const
fml
::
closure
&
closure
)
override
{}
void
OnPlatformViewSetViewportMetrics
(
const
ViewportMetrics
&
metrics
)
override
{}
void
OnPlatformViewDispatchPlatformMessage
(
fml
::
RefPtr
<
PlatformMessage
>
message
)
override
{}
void
OnPlatformViewDispatchPointerDataPacket
(
std
::
unique_ptr
<
PointerDataPacket
>
packet
)
override
{
}
void
OnPlatformViewDispatchSemanticsAction
(
int32_t
id
,
SemanticsAction
action
,
std
::
vector
<
uint8_t
>
args
)
override
{}
void
OnPlatformViewSetSemanticsEnabled
(
bool
enabled
)
override
{}
void
OnPlatformViewSetAccessibilityFeatures
(
int32_t
flags
)
override
{}
void
OnPlatformViewRegisterTexture
(
std
::
shared_ptr
<
Texture
>
texture
)
override
{}
void
OnPlatformViewUnregisterTexture
(
int64_t
texture_id
)
override
{}
void
OnPlatformViewMarkTextureFrameAvailable
(
int64_t
texture_id
)
override
{}
std
::
unique_ptr
<
std
::
vector
<
std
::
string
>>
ComputePlatformViewResolvedLocale
(
const
std
::
vector
<
std
::
string
>&
supported_locale_data
)
override
{
std
::
unique_ptr
<
std
::
vector
<
std
::
string
>>
out
=
std
::
make_unique
<
std
::
vector
<
std
::
string
>>
();
return
out
;
}
};
}
// namespace
}
// namespace flutter
@interface
FlutterEnginePlatformViewTest
:
XCTestCase
@end
@implementation
FlutterEnginePlatformViewTest
-
(
void
)
setUp
{
fml
::
MessageLoop
::
EnsureInitializedForCurrentThread
();
}
-
(
void
)
tearDown
{
}
-
(
void
)
testCallsNotifyLowMemory
{
flutter
::
MockDelegate
mock_delegate
;
auto
thread_task_runner
=
fml
::
MessageLoop
::
GetCurrent
().
GetTaskRunner
();
flutter
::
TaskRunners
runners
(
/*label=*/
self
.
name
.
UTF8String
,
/*platform=*/
thread_task_runner
,
/*raster=*/
thread_task_runner
,
/*ui=*/
thread_task_runner
,
/*io=*/
thread_task_runner
);
auto
platform_view
=
std
::
make_unique
<
flutter
::
PlatformViewIOS
>
(
/*delegate=*/
mock_delegate
,
/*rendering_api=*/
flutter
::
IOSRenderingAPI
::
kSoftware
,
/*task_runners=*/
runners
);
id
project
=
OCMClassMock
([
FlutterDartProject
class
]);
FlutterEngine
*
engine
=
[[
FlutterEngine
alloc
]
initWithName
:
@"tester"
project
:
project
];
XCTAssertNotNil
(
engine
);
id
mockEngine
=
OCMPartialMock
(
engine
);
OCMStub
([
mockEngine
notifyLowMemory
]);
OCMStub
([
mockEngine
iosPlatformView
]).
andReturn
(
platform_view
.
get
());
[
engine
setViewController
:
nil
];
OCMVerify
([
mockEngine
notifyLowMemory
]);
OCMReject
([
mockEngine
notifyLowMemory
]);
[[
NSNotificationCenter
defaultCenter
]
postNotificationName:
UIApplicationDidReceiveMemoryWarningNotification
object:
nil
];
OCMVerify
([
mockEngine
notifyLowMemory
]);
OCMReject
([
mockEngine
notifyLowMemory
]);
[[
NSNotificationCenter
defaultCenter
]
postNotificationName:
UIApplicationDidEnterBackgroundNotification
object:
nil
];
OCMVerify
([
mockEngine
notifyLowMemory
]);
}
@end
shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h
浏览文件 @
eab9b7f2
...
...
@@ -45,6 +45,8 @@
-
(
void
)
launchEngine
:(
NSString
*
)
entrypoint
libraryURI
:(
NSString
*
)
libraryOrNil
;
-
(
BOOL
)
createShell
:(
NSString
*
)
entrypoint
libraryURI
:(
NSString
*
)
libraryOrNil
;
-
(
void
)
attachView
;
-
(
void
)
notifyLowMemory
;
-
(
flutter
::
PlatformViewIOS
*
)
iosPlatformView
;
@end
...
...
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
浏览文件 @
eab9b7f2
...
...
@@ -557,6 +557,7 @@ static void sendFakeTouchEvent(FlutterEngine* engine,
[
self
surfaceUpdated
:
NO
];
[[
_engine
.
get
()
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.paused"
];
[
self
flushOngoingTouches
];
[
_engine
.
get
()
notifyLowMemory
];
}
[
super
viewDidDisappear
:
animated
];
...
...
shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
浏览文件 @
eab9b7f2
...
...
@@ -16,6 +16,10 @@ FLUTTER_ASSERT_ARC
-
(
BOOL
)
createShell
:(
NSString
*
)
entrypoint
libraryURI
:(
NSString
*
)
libraryURI
;
@end
@interface
FlutterEngine
(
TestLowMemory
)
-
(
void
)
notifyLowMemory
;
@end
extern
NSNotificationName
const
FlutterViewControllerWillDealloc
;
/// A simple mock class for FlutterEngine.
...
...
@@ -529,4 +533,18 @@ typedef enum UIAccessibilityContrast : NSInteger {
XCTAssertTrue
(
realVC
.
prefersHomeIndicatorAutoHidden
,
@""
);
}
-
(
void
)
testNotifyLowMemory
{
id
engine
=
OCMClassMock
([
FlutterEngine
class
]);
FlutterViewController
*
viewController
=
[[
FlutterViewController
alloc
]
initWithEngine
:
engine
nibName:
nil
bundle:
nil
];
OCMStub
([
engine
viewController
]).
andReturn
(
viewController
);
id
viewControllerMock
=
OCMPartialMock
(
viewController
);
OCMStub
([
viewControllerMock
surfaceUpdated
:
NO
]);
[
viewController
beginAppearanceTransition
:
NO
animated
:
NO
];
[
viewController
endAppearanceTransition
];
OCMVerify
([
engine
notifyLowMemory
]);
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录