-
Notifications
You must be signed in to change notification settings - Fork 6k
Run setAssetBundlePath outside of UI thread. #4939
Conversation
Running this on UI thread results in timeout if application is suspended on breakpoint and UI loop is not running. There is no reason to run setAssetBundlePath on UI thread as this request only updates internal asset location.
|
@chinmaygarde is this still relevant after the engine refactoring? |
…ons of SetAssetBundlePath into single one.
|
This lgtm, but I'd wait for Chinmay's answer. |
|
Yes. This will still be an issue in the refactor because this service protocol method requires a response object to say if the updated asset bundle of was actually installed on the running shell. https://docs.google.com/document/d/1ObJYEfw3xtL_UW-aBCIODhZzFyzLrEVCYDeio1GVIuE/edit#heading=h.2ejbd9fwvkxi. There is no way to determine this upfront. This implementation only tries to find the particular flutter view and fails if it cant. It is possible that the directory specified is invalid, in such cases, the new asset bundle wont be installed but the service protocol response will be a success. |
|
The refactor has also removed all the extra per platform overrides to set the asset bundle on the UI thread. So that part is not relevant anymore. |
|
I don't think this is the right (or complete) fix for the linked issue. There are other methods (namely |
chinmaygarde
left a comment
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.
Based on comments above.
|
After talking to @rmacnak-google, some suggestions: The plan then is to use the same mechanism the VM uses to run the callbacks specified using |
|
@chinmaygarde wrote:
Linked issue and the fix is specifically about flutter tools hanging during hot reload. Those other methods( I don't think that this fix for M3 issue should be held until we figure out more generic solution that would avoid scheduling actions on UI thread. |
I don't this is true, the issue mentions hot
If we need a quick hack for this, the workaround mentioned in this comment should be the way to go. This is because the shell refactor I want to land in this patch separates service protocol registration and dispatch into a generic API that is used by the components that care to respond via the service protocol. So it will be hard to apply the workaround for just this one method in that patch. |
We were not able to repro "restart issue", but were able to identify "hot reload issue" - see flutter/flutter#13396 (comment). So this is what this fixes. |
Like I mentioned on flutter/flutter#13396 (comment) always switching asset bundle path even if hot reload won't be used doesn't feel right. |
chinmaygarde
left a comment
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.
always switching asset bundle path even if hot reload won't be used doesn't feel right.
Neither does this. And it will be hard to reconcile with the changes in the linked PR. But I'll figure something out. We should still file a bug saying that not all service protocol handlers that need the UI thread are resilient to pauses in the debugger. I suspect we will keep running into more such edge cases. Feel free to assign the issue to me.
|
What is the status of this PR? Can we close it for now while the fix is refactored? |
Sure thing. |
Waiting for setAssetBundlePath running this on UI thread could result in timeout since application could be suspended on breakpoint with UI loop not running. So we just post setAssetBundlePath call on UI event queue and don't wait.
Refactor and remove extra layers of running-on-UI methods.
This fixes flutter/flutter#13396