Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
1cbbd119
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
未验证
提交
1cbbd119
编写于
3月 09, 2021
作者:
R
Ren You
提交者:
GitHub
3月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Fix memory leak and bug in the RunsOnCreationTaskRunner check (#24690)" (#24874)
This reverts commit
735876ed
.
上级
7764b5c5
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
6 addition
and
181 deletion
+6
-181
fml/memory/task_runner_checker.cc
fml/memory/task_runner_checker.cc
+2
-6
fml/memory/task_runner_checker.h
fml/memory/task_runner_checker.h
+0
-1
fml/memory/task_runner_checker_unittest.cc
fml/memory/task_runner_checker_unittest.cc
+0
-52
fml/message_loop_task_queues.cc
fml/message_loop_task_queues.cc
+1
-8
fml/message_loop_task_queues.h
fml/message_loop_task_queues.h
+0
-4
fml/message_loop_task_queues_unittests.cc
fml/message_loop_task_queues_unittests.cc
+0
-7
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
...d/io/flutter/plugin/platform/PlatformViewsController.java
+0
-4
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
.../flutter/plugin/platform/PlatformViewsControllerTest.java
+0
-55
testing/scenario_app/android/app/build.gradle
testing/scenario_app/android/app/build.gradle
+3
-9
testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java
...oidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java
+0
-34
testing/scenario_app/android/app/src/main/res/values/strings.xml
.../scenario_app/android/app/src/main/res/values/strings.xml
+0
-1
未找到文件。
fml/memory/task_runner_checker.cc
浏览文件 @
1cbbd119
...
...
@@ -7,18 +7,14 @@
namespace
fml
{
TaskRunnerChecker
::
TaskRunnerChecker
()
:
initialized_queue_id_
(
InitTaskQueueId
()),
subsumed_queue_id_
(
MessageLoopTaskQueues
::
GetInstance
()
->
GetSubsumedTaskQueueId
(
initialized_queue_id_
)){};
:
initialized_queue_id_
(
InitTaskQueueId
()){};
TaskRunnerChecker
::~
TaskRunnerChecker
()
=
default
;
bool
TaskRunnerChecker
::
RunsOnCreationTaskRunner
()
const
{
FML_CHECK
(
fml
::
MessageLoop
::
IsInitializedForCurrentThread
());
const
auto
current_queue_id
=
MessageLoop
::
GetCurrentTaskQueueId
();
return
RunsOnTheSameThread
(
current_queue_id
,
initialized_queue_id_
)
||
RunsOnTheSameThread
(
current_queue_id
,
subsumed_queue_id_
);
return
RunsOnTheSameThread
(
current_queue_id
,
initialized_queue_id_
);
};
bool
TaskRunnerChecker
::
RunsOnTheSameThread
(
TaskQueueId
queue_a
,
...
...
fml/memory/task_runner_checker.h
浏览文件 @
1cbbd119
...
...
@@ -22,7 +22,6 @@ class TaskRunnerChecker final {
private:
TaskQueueId
initialized_queue_id_
;
TaskQueueId
subsumed_queue_id_
;
TaskQueueId
InitTaskQueueId
();
};
...
...
fml/memory/task_runner_checker_unittest.cc
浏览文件 @
1cbbd119
...
...
@@ -115,57 +115,5 @@ TEST(TaskRunnerCheckerTests, MergedTaskRunnersRunsOnTheSameThread) {
thread2
.
join
();
}
TEST
(
TaskRunnerCheckerTests
,
PassesRunsOnCreationTaskRunnerIfOnDifferentTaskRunner
)
{
fml
::
MessageLoop
*
loop1
=
nullptr
;
fml
::
AutoResetWaitableEvent
latch1
;
std
::
thread
thread1
([
&
]()
{
fml
::
MessageLoop
::
EnsureInitializedForCurrentThread
();
loop1
=
&
fml
::
MessageLoop
::
GetCurrent
();
latch1
.
Signal
();
loop1
->
Run
();
});
fml
::
MessageLoop
*
loop2
=
nullptr
;
fml
::
AutoResetWaitableEvent
latch2
;
std
::
thread
thread2
([
&
]()
{
fml
::
MessageLoop
::
EnsureInitializedForCurrentThread
();
loop2
=
&
fml
::
MessageLoop
::
GetCurrent
();
latch2
.
Signal
();
loop2
->
Run
();
});
latch1
.
Wait
();
latch2
.
Wait
();
fml
::
TaskQueueId
qid1
=
loop1
->
GetTaskRunner
()
->
GetTaskQueueId
();
fml
::
TaskQueueId
qid2
=
loop2
->
GetTaskRunner
()
->
GetTaskQueueId
();
fml
::
MessageLoopTaskQueues
::
GetInstance
()
->
Merge
(
qid1
,
qid2
);
std
::
unique_ptr
<
TaskRunnerChecker
>
checker
;
fml
::
AutoResetWaitableEvent
latch3
;
loop2
->
GetTaskRunner
()
->
PostTask
([
&
]()
{
checker
=
std
::
make_unique
<
TaskRunnerChecker
>
();
EXPECT_EQ
(
checker
->
RunsOnCreationTaskRunner
(),
true
);
latch3
.
Signal
();
});
latch3
.
Wait
();
fml
::
MessageLoopTaskQueues
::
GetInstance
()
->
Unmerge
(
qid1
);
fml
::
AutoResetWaitableEvent
latch4
;
loop2
->
GetTaskRunner
()
->
PostTask
([
&
]()
{
EXPECT_EQ
(
checker
->
RunsOnCreationTaskRunner
(),
true
);
latch4
.
Signal
();
});
latch4
.
Wait
();
loop1
->
Terminate
();
loop2
->
Terminate
();
thread1
.
join
();
thread2
.
join
();
}
}
// namespace testing
}
// namespace fml
fml/message_loop_task_queues.cc
浏览文件 @
1cbbd119
...
...
@@ -238,14 +238,7 @@ bool MessageLoopTaskQueues::Unmerge(TaskQueueId owner) {
bool
MessageLoopTaskQueues
::
Owns
(
TaskQueueId
owner
,
TaskQueueId
subsumed
)
const
{
std
::
lock_guard
guard
(
queue_mutex_
);
return
owner
!=
_kUnmerged
&&
subsumed
!=
_kUnmerged
&&
subsumed
==
queue_entries_
.
at
(
owner
)
->
owner_of
;
}
TaskQueueId
MessageLoopTaskQueues
::
GetSubsumedTaskQueueId
(
TaskQueueId
owner
)
const
{
std
::
lock_guard
guard
(
queue_mutex_
);
return
queue_entries_
.
at
(
owner
)
->
owner_of
;
return
subsumed
==
queue_entries_
.
at
(
owner
)
->
owner_of
;
}
// Subsumed queues will never have pending tasks.
...
...
fml/message_loop_task_queues.h
浏览文件 @
1cbbd119
...
...
@@ -122,10 +122,6 @@ class MessageLoopTaskQueues
// Returns true if owner owns the subsumed task queue.
bool
Owns
(
TaskQueueId
owner
,
TaskQueueId
subsumed
)
const
;
// Returns the subsumed task queue if any or |TaskQueueId::kUnmerged|
// otherwise.
TaskQueueId
GetSubsumedTaskQueueId
(
TaskQueueId
owner
)
const
;
private:
class
MergedQueuesRunner
;
...
...
fml/message_loop_task_queues_unittests.cc
浏览文件 @
1cbbd119
...
...
@@ -185,13 +185,6 @@ TEST(MessageLoopTaskQueue, QueueDoNotOwnItself) {
ASSERT_FALSE
(
task_queue
->
Owns
(
queue_id
,
queue_id
));
}
TEST
(
MessageLoopTaskQueue
,
QueueDoNotOwnUnmergedTaskQueueId
)
{
auto
task_queue
=
fml
::
MessageLoopTaskQueues
::
GetInstance
();
ASSERT_FALSE
(
task_queue
->
Owns
(
task_queue
->
CreateTaskQueue
(),
_kUnmerged
));
ASSERT_FALSE
(
task_queue
->
Owns
(
_kUnmerged
,
task_queue
->
CreateTaskQueue
()));
ASSERT_FALSE
(
task_queue
->
Owns
(
_kUnmerged
,
_kUnmerged
));
}
// TODO(chunhtai): This unit-test is flaky and sometimes fails asynchronizely
// after the test has finished.
// https://github.com/flutter/flutter/issues/43858
...
...
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
浏览文件 @
1cbbd119
...
...
@@ -458,7 +458,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
if
(
platformViewsChannel
!=
null
)
{
platformViewsChannel
.
setPlatformViewsHandler
(
null
);
}
destroyOverlaySurfaces
();
platformViewsChannel
=
null
;
context
=
null
;
textureRegistry
=
null
;
...
...
@@ -762,9 +761,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
}
public
void
onDisplayOverlaySurface
(
int
id
,
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
overlayLayerViews
.
get
(
id
)
==
null
)
{
throw
new
IllegalStateException
(
"The overlay surface (id:"
+
id
+
") doesn't exist"
);
}
initializeRootImageViewIfNeeded
();
final
FlutterImageView
overlayView
=
overlayLayerViews
.
get
(
id
);
...
...
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
浏览文件 @
1cbbd119
...
...
@@ -498,61 +498,6 @@ public class PlatformViewsControllerTest {
assertEquals
(
flutterView
.
getChildCount
(),
1
);
}
@Test
@Config
(
shadows
=
{
ShadowFlutterSurfaceView
.
class
,
ShadowFlutterJNI
.
class
})
public
void
detach__destroysOverlaySurfaces
()
{
final
PlatformViewsController
platformViewsController
=
new
PlatformViewsController
();
final
int
platformViewId
=
0
;
assertNull
(
platformViewsController
.
getPlatformViewById
(
platformViewId
));
final
PlatformViewFactory
viewFactory
=
mock
(
PlatformViewFactory
.
class
);
final
PlatformView
platformView
=
mock
(
PlatformView
.
class
);
when
(
platformView
.
getView
()).
thenReturn
(
mock
(
View
.
class
));
when
(
viewFactory
.
create
(
any
(),
eq
(
platformViewId
),
any
())).
thenReturn
(
platformView
);
platformViewsController
.
getRegistry
().
registerViewFactory
(
"testType"
,
viewFactory
);
final
FlutterJNI
jni
=
new
FlutterJNI
();
jni
.
attachToNative
(
false
);
attach
(
jni
,
platformViewsController
);
jni
.
onFirstFrame
();
// Simulate create call from the framework.
createPlatformView
(
jni
,
platformViewsController
,
platformViewId
,
"testType"
);
// Produce a frame that displays a platform view and an overlay surface.
platformViewsController
.
onBeginFrame
();
platformViewsController
.
onDisplayPlatformView
(
platformViewId
,
/* x=*/
0
,
/* y=*/
0
,
/* width=*/
10
,
/* height=*/
10
,
/* viewWidth=*/
10
,
/* viewHeight=*/
10
,
/* mutatorsStack=*/
new
FlutterMutatorsStack
());
final
FlutterImageView
overlayImageView
=
mock
(
FlutterImageView
.
class
);
when
(
overlayImageView
.
acquireLatestImage
()).
thenReturn
(
true
);
final
FlutterOverlaySurface
overlaySurface
=
platformViewsController
.
createOverlaySurface
(
overlayImageView
);
// This is OK.
platformViewsController
.
onDisplayOverlaySurface
(
overlaySurface
.
getId
(),
/* x=*/
0
,
/* y=*/
0
,
/* width=*/
10
,
/* height=*/
10
);
platformViewsController
.
detach
();
assertThrows
(
IllegalStateException
.
class
,
()
->
{
platformViewsController
.
onDisplayOverlaySurface
(
overlaySurface
.
getId
(),
/* x=*/
0
,
/* y=*/
0
,
/* width=*/
10
,
/* height=*/
10
);
});
}
@Test
public
void
checkInputConnectionProxy__falseIfViewIsNull
()
{
final
PlatformViewsController
platformViewsController
=
new
PlatformViewsController
();
...
...
testing/scenario_app/android/app/build.gradle
浏览文件 @
1cbbd119
apply
plugin:
'com.android.application'
apply
plugin:
'com.facebook.testing.screenshot'
def
leakcanary_version
=
'2.6'
screenshots
{
failureDir
=
"${rootProject.buildDir}/reports/diff_failures"
recordDir
=
"${rootProject.projectDir}/reports/screenshots"
...
...
@@ -15,14 +13,12 @@ android {
targetCompatibility
JavaVersion
.
VERSION_1_8
}
defaultConfig
{
applicationId
'dev.flutter.scenarios'
applicationId
"dev.flutter.scenarios"
minSdkVersion
18
targetSdkVersion
30
versionCode
1
versionName
'1.0'
testInstrumentationRunner
'dev.flutter.TestRunner'
testInstrumentationRunnerArgument
'listener'
,
'leakcanary.FailTestOnLeakRunListener'
testInstrumentationRunnerArguments
clearPackageData:
'true'
versionName
"1.0"
testInstrumentationRunner
"dev.flutter.TestRunner"
}
buildTypes
{
release
{
...
...
@@ -42,10 +38,8 @@ dependencies {
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'com.google.android.material:material:1.0.0'
implementation
'androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha01'
implementation
"com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test:rules:1.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation
"com.squareup.leakcanary:leakcanary-android-instrumentation:$leakcanary_version"
}
testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/MemoryLeakTests.java
已删除
100644 → 0
浏览文件 @
7764b5c5
// 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.
package
dev.flutter.scenariosui
;
import
android.content.Intent
;
import
androidx.test.filters.LargeTest
;
import
androidx.test.rule.ActivityTestRule
;
import
androidx.test.runner.AndroidJUnit4
;
import
dev.flutter.scenarios.TextPlatformViewActivity
;
import
leakcanary.FailTestOnLeak
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
AndroidJUnit4
.
class
)
@LargeTest
public
class
MemoryLeakTests
{
@Rule
public
ActivityTestRule
<
TextPlatformViewActivity
>
activityRule
=
new
ActivityTestRule
<>(
TextPlatformViewActivity
.
class
,
/*initialTouchMode=*/
false
,
/*launchActivity=*/
false
);
@Test
@FailTestOnLeak
public
void
platformViewHybridComposition_launchActivityFinishAndLaunchAgain
()
throws
Exception
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
putExtra
(
"scenario"
,
"platform_view"
);
intent
.
putExtra
(
"use_android_view"
,
true
);
activityRule
.
launchActivity
(
intent
);
}
}
testing/scenario_app/android/app/src/main/res/values/strings.xml
浏览文件 @
1cbbd119
<resources>
<string
name=
"app_name"
>
Scenarios
</string>
<string
name=
"title_activity_main"
>
MainActivity
</string>
<string
name=
"leak_canary_test_class_name"
>
assertk.Assert
</string>
</resources>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录