-
-
Notifications
You must be signed in to change notification settings - Fork 650
[WIP] feat: assetPath hook #3403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat: assetPath hook #3403
Conversation
tokio::runtime::Handle::current().block_on(async move { | ||
self | ||
.plugin_driver | ||
.write() |
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.
This will be stuck if you would like to call this method from a JS Hook. As Rust called the JS hook in which you called this method is write
, and if you call get_asset_path
method, then, Rust calls the write
of plugin_driver
again, which leads to a deadlock. The only way to solve this is to call the plugin_driver
as read
.
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.
it doesn't seem to help unfortunately. I've pushed a small commit so that get_asset_path
method is async now and plugin_driver
is called as read
.
Are there any other ways to overcome this issue? As I can see we can't really invoke the hook from elsewhere or at another point of time, right?
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.
Are there any other ways to overcome this issue? As I can see we can't really invoke the hook from elsewhere or at another point of time, right?
If you want to acquire the mutable reference as what write
does, you can only invoke the hook one at the time. But for hooks that only requires read
, it does not have the limitation, which means you can invoke as much as you wish.
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.
@h-a-n-a can you please point me what exactly should be changed in my implementation? I tried both read and write accesses and behavior is the same
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.
The deadlock problem has been resolved in #3455. You may continue to implement this hook. Thank you in advance!
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.
Thanks a lot @h-a-n-a !
43e4a93
to
c9025c3
Compare
c9025c3
to
d74cacd
Compare
@h-a-n-a this PR is pretty much ready, but there's an error Any ideas how this can be avoided? |
This is mainly because of the code that you're trying to run is not running in the context of Tokio runtime. You should create one in this case. |
@h-a-n-a I've tried doing that but looks like I'm not able to come up with functional code. Would you be so kind to provide me a snippet how |
Would you mind if I push some code to this PR? |
Absolutely not! |
After I dig into this PR, I found out there's basically an issue about multi-thread and single-thread interoperation. Details will be added later. |
I initiated a discussion here: #3642 . Please allow me to set this PR to on -hold for now until we settle down to a solution. |
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
not stale |
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
not stale |
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
not stale |
This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump"). |
!bench |
we will revisit when we find solution |
No description provided.