Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Nov 17, 2023

  • New EngineFlutterView.dispose() to cleanup when the view is removed (and in hot restart).
  • EnginePlatformDispatcher.dispose() now disposes of all of its registered views.

@mdebbar mdebbar requested review from ditman and yjbanov November 17, 2023 17:06
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Nov 17, 2023
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments/questions.

Comment on lines 187 to 193
final class _EngineFlutterViewImpl extends EngineFlutterView {
_EngineFlutterViewImpl(
super.viewId,
super.platformDispatcher,
super.hostElement,
) : super._() {
registerHotRestartListener(() {
// TODO(harryterkelsen): What should we do about this in multi-view?
renderer.clearFragmentProgramCache();
_dimensionsProvider.close();
});
}
) : super._();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension is unneeded now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still needed to tell the compiler which super constructor I want to use (it's not the default constructor).

@override
void render(ui.Scene scene) => platformDispatcher.render(scene, this);
void render(ui.Scene scene) {
assert(!isDisposed, 'Trying to render a disposed EngineFlutterView.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure, but I think this should not be an assert, just a noop.

(Also since this is being called from views[id].render(), it's likely that this assert will only be exercised in test code, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also since this is being called from views[id].render(), it's likely that this assert will only be exercised in test code, right?)

In theory, yes. In practice, the assert here serves as a guard against bugs in our logic if we somehow try to render to a disposed view.

If the framework tries to render to a disposed view, then the platform dispatcher (or renderer) should do viewData[id]?.render(scene) (which would fail to find the view, and it'll be a noop). I don't think we should allow calling render directly on a disposed view.

@override
void updateSemantics(ui.SemanticsUpdate update) => platformDispatcher.updateSemantics(update);
void updateSemantics(ui.SemanticsUpdate update) {
assert(!isDisposed, 'Trying to update semantics on a disposed EngineFlutterView.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Similar comment to the one in the render method)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Similar reply) :P

@mustCallSuper
void dispose() {
isDisposed = true;
platformDispatcher.unregisterView(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the view constructor is automatically doing register, and this needs to be here (but we said that registration wouldn't happen automatically upon creation, so this will go in that case, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. dispose should undo anything that this class did. If the view is registering itself, then it should also unregister itself (in dispose). If someone else is registering the view, then that someone should handle the unregistering too.

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2023
@auto-submit auto-submit bot merged commit 255f967 into flutter:main Nov 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 20, 2023
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Nov 20, 2023
…138739)

flutter/engine@1f1e26c...255f967

2023-11-20 mdebbar@google.com [web] EngineFlutterView.dispose() (flutter/engine#48183)
2023-11-20 skia-flutter-autoroll@skia.org Roll Skia from 64d1e14df168 to 795a259c2f56 (2 revisions) (flutter/engine#48227)
2023-11-20 skia-flutter-autoroll@skia.org Roll Skia from a874e29d71c0 to 64d1e14df168 (1 revision) (flutter/engine#48225)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jonahwilliams@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@mdebbar mdebbar deleted the view_dispose branch November 20, 2023 22:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants