Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0cc7db54
Unverified
Commit
0cc7db54
authored
Jul 28, 2022
by
Dan Field
Committed by
GitHub
Jul 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guard against usage after async callbacks in RenderAndroidView, unregister listener (#108496)
parent
b1881487
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
+49
-3
platform_view.dart
packages/flutter/lib/src/rendering/platform_view.dart
+9
-0
platform_view_test.dart
packages/flutter/test/rendering/platform_view_test.dart
+39
-0
fake_platform_views.dart
packages/flutter/test/services/fake_platform_views.dart
+1
-3
No files found.
packages/flutter/lib/src/rendering/platform_view.dart
View file @
0cc7db54
...
...
@@ -109,6 +109,7 @@ class RenderAndroidView extends PlatformViewRenderBox {
/// Sets a new Android view controller.
@override
set
controller
(
AndroidViewController
controller
)
{
assert
(!
_isDisposed
);
assert
(
_viewController
!=
null
);
assert
(
controller
!=
null
);
if
(
_viewController
==
controller
)
{
...
...
@@ -140,6 +141,7 @@ class RenderAndroidView extends PlatformViewRenderBox {
}
void
_onPlatformViewCreated
(
int
id
)
{
assert
(!
_isDisposed
);
markNeedsSemanticsUpdate
();
}
...
...
@@ -179,8 +181,14 @@ class RenderAndroidView extends PlatformViewRenderBox {
targetSize
=
size
;
if
(
_viewController
.
isCreated
)
{
_currentTextureSize
=
await
_viewController
.
setSize
(
targetSize
);
if
(
_isDisposed
)
{
return
;
}
}
else
{
await
_viewController
.
create
(
size:
targetSize
);
if
(
_isDisposed
)
{
return
;
}
_currentTextureSize
=
targetSize
;
}
// We've resized the platform view to targetSize, but it is possible that
...
...
@@ -248,6 +256,7 @@ class RenderAndroidView extends PlatformViewRenderBox {
void
dispose
()
{
_isDisposed
=
true
;
_clipRectLayer
.
layer
=
null
;
_viewController
.
removeOnPlatformViewCreatedListener
(
_onPlatformViewCreated
);
super
.
dispose
();
}
...
...
packages/flutter/test/rendering/platform_view_test.dart
View file @
0cc7db54
...
...
@@ -221,6 +221,45 @@ void main() {
expect
(
renderBox
.
debugLayer
!.
firstChild
,
isA
<
TextureLayer
>());
});
});
test
(
'markNeedsPaint does not get called on a disposed RO'
,
()
async
{
FakeAsync
().
run
((
FakeAsync
async
)
{
final
AndroidViewController
viewController
=
PlatformViewsService
.
initAndroidView
(
id:
0
,
viewType:
'webview'
,
layoutDirection:
TextDirection
.
rtl
);
final
RenderAndroidView
renderBox
=
RenderAndroidView
(
viewController:
viewController
,
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{},
);
final
Completer
<
void
>
viewCreation
=
Completer
<
void
>();
const
MethodChannel
channel
=
MethodChannel
(
'flutter/platform_views'
);
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
channel
,
(
MethodCall
methodCall
)
async
{
assert
(
methodCall
.
method
==
'create'
,
'Unexpected method call'
);
await
viewCreation
.
future
;
return
/*textureId=*/
0
;
});
layout
(
renderBox
);
pumpFrame
(
phase:
EnginePhase
.
paint
);
expect
(
renderBox
.
debugLayer
,
isNotNull
);
expect
(
renderBox
.
debugLayer
!.
hasChildren
,
isFalse
);
expect
(
viewController
.
isCreated
,
isFalse
);
expect
(
renderBox
.
debugNeedsPaint
,
isFalse
);
renderBox
.
dispose
();
viewCreation
.
complete
();
async
.
flushMicrotasks
();
expect
(
viewController
.
isCreated
,
isTrue
);
expect
(
renderBox
.
debugNeedsPaint
,
isFalse
);
expect
(
renderBox
.
debugLayer
,
isNull
);
pumpFrame
(
phase:
EnginePhase
.
paint
);
expect
(
renderBox
.
debugLayer
,
isNull
);
});
});
}
ui
.
PointerData
_pointerData
(
...
...
packages/flutter/test/services/fake_platform_views.dart
View file @
0cc7db54
...
...
@@ -101,9 +101,7 @@ class FakeAndroidViewController implements AndroidViewController {
}
@override
void
removeOnPlatformViewCreatedListener
(
PlatformViewCreatedCallback
listener
)
{
throw
UnimplementedError
();
}
void
removeOnPlatformViewCreatedListener
(
PlatformViewCreatedCallback
listener
)
{}
@override
Future
<
void
>
sendMotionEvent
(
AndroidMotionEvent
event
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment