Skip to content
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

vscode support: onview activation event doesn't work for a custom webview view #13157

Open
jcortell68 opened this issue Dec 6, 2023 · 8 comments
Labels
bug bugs found in the application plug-in system issues related to the plug-in system

Comments

@jcortell68
Copy link
Contributor

jcortell68 commented Dec 6, 2023

Bug Description:

When a vscode extension contributes a custom view that is a webview, and it declares an activation event for the view being opened (onview:myviewid), the plugin doesn't get activated when opening the view and the view shows no content.

One workaround is to declare * as an activation event but that is obviously not ideal. We don't want the plugin activated if the user isn't going to open the view.

Also, for whatever reason, the plugin is properly activated if the app launches with the view already opened. I.e., if the user restarts/refreshes the app with the view already open, then the plugin is activated and everything works as expected.

Steps to Reproduce:

git clone -b webview_panel_noneditor https://github.com/jcortell68/theiasandbox
cd theiasandbox
yarn
yarn start:electron
  1. Bring up the command palette (Ctrl+Shift+p on Windows) and trigger the View: Reset Workbench Layout command.
  2. Wait for the app to refresh
  3. Open the custom view via View > Open View... > My Webview
  4. Notice the view comes up but is empty. It should be saying hello to the world.
  5. Notice that the stdout lacks the console.log() that the plugin writes from it's activation event (Congratulations, your extension "myext" is now active...). This proves that the plugin was not activated, despite having this in its package.json
"activationEvents": ["onView:myext_myView"],
  1. Refresh the app (Ctrl+r on Windows).
  2. Notice the custom view is now showing the expected content.

For further proof that the activation event isn't working, change activationEvents so that the plugin is activated on launch unconditionally:

"activationEvents": ["*"],

Now try to reproduce the problem following the steps above and you'll see the empty view behavior doesn't happen.

Finally, the problem happens whether or not the custom view is in a custom view container. In the example plugin provided, a custom view container is used. But declaring the view to be within the built-in explorer container instead results in the same buggy behavior.

Additional Information

  • Operating System: Windows
  • Theia Version: 1.43.1
@jcortell68
Copy link
Contributor Author

@martin-fleck-at reproduced the issue on his machine

@jcortell68 jcortell68 changed the title vscode support: onview activation event doesn't work for a custom view in a custom view container vscode support: onview activation event doesn't work for a custom view Dec 6, 2023
@jcortell68 jcortell68 changed the title vscode support: onview activation event doesn't work for a custom view vscode support: onview activation event doesn't work for a custom webview view Dec 6, 2023
@msujew
Copy link
Member

msujew commented Dec 6, 2023

Maybe related to #13090.

@jcortell68
Copy link
Contributor Author

I'd say almost certainly. Thanks.

@msujew msujew added bug bugs found in the application plug-in system issues related to the plug-in system labels Dec 20, 2023
@msujew
Copy link
Member

msujew commented Dec 21, 2023

I've encountered this issue when trying to test #13091. While the effects are very similar to the other issue, they have independent problem sources. My findings during a short debugging session:

@jcortell68
Copy link
Contributor Author

I've encountered this issue when trying to test #13091. While the effects are very similar to the other issue, they have independent problem sources.

Oh wow. Very surprising indeed. Thanks for attempting to verify my issue while fixing the other one. There's no shortage of work for you Theia folks in 2024 ;-)

@jcortell68
Copy link
Contributor Author

BTW, on a somewhat separate but related note, does Theia not support VSCode's implicit/automatic activationEvent registration that was introduced in 1.74.0?

@msujew
Copy link
Member

msujew commented Dec 21, 2023

@jcortell68 It does support it see #12167. The event generator for onView just wasn't implemented correctly, which has been fixed by #13091.

@jcortell68
Copy link
Contributor Author

Yep. I get that the onView support was broken. I just honestly didn't know if the 1.74.0 auto feature was in Theia or not. Of course, when I ran into my bug (described in this ticket), I didn't explicitly declare the activationEvent and thought that was what was causing the broken behavior. I was wrong, of course. But I just realized I didn't know if the auto-behavior was in Theia. Glad to know it is! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application plug-in system issues related to the plug-in system
Projects
None yet
Development

No branches or pull requests

2 participants