-
Notifications
You must be signed in to change notification settings - Fork 6k
Flush all embedded Android views on hot restart. #5929
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -740,6 +740,21 @@ void Shell::OnEngineHandlePlatformMessage( | |
| }); | ||
| } | ||
|
|
||
| // |shell::Engine::Delegate| | ||
| void Shell::OnEngineRestart() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will deadlock on configurations where the task runners are the same (test/embedder configurations). Please use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the assertions for setup and the thread checker as done in all the other methods in this file.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow good catch on the threading issue! thanks!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the same assertions, though I believe we don't really care to assert that we're on the ui thread
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we are just being super paranoid about threading here. Also, I like the assertion as a nice way of quickly figuring out who initiates the restart call. For example, it is possible that the service protocol handler fires off this delegate method. But now that you added the assertion, I can easily tell that the engine has had a chance to service the call. |
||
| fml::AutoResetWaitableEvent latch; | ||
| task_runners_.GetPlatformTaskRunner()->PostTask( | ||
| [view = platform_view_->GetWeakPtr(), &latch] { | ||
| if (view) { | ||
| view->OnEngineRestart(); | ||
| } | ||
| latch.Signal(); | ||
| }); | ||
| // This is blocking as any embedded platform views has to be flushed before | ||
| // we re-run the Dart code. | ||
| latch.Wait(); | ||
| } | ||
|
|
||
| // |blink::ServiceProtocol::Handler| | ||
| fml::RefPtr<fml::TaskRunner> Shell::GetServiceProtocolHandlerTaskRunner( | ||
| fml::StringView method) const { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to check if the run call actually succeeded before firing the delegate method. As written, failed attempts to relaunch the engine will still fire the delegate callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a problem - I need to make sure I flushed the embedded views before the dart code starts...
What happens when a hot restart fails? do we retry? what if all retries failed?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a hot restart fails, we just sit there waiting for another restart (all restarts are initiated by the service protocol).
If you really want a callback just before the restart, I would name this delegate method
OnEngineWillRestartto better indicate that the restart has not yet happened. Also, move this delegate call up before theruntime_controller_->Clone()call. On line 106, the old runtime controller has already been destroyed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Renamed to
OnPreEngineRestart