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

WIP: Use Messenger with named target for sidebar panel rendering #1695

Closed
wants to merge 16 commits into from

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Oct 19, 2021

Not ready for review

Second part to:

Related/included:

Questions:

  • Are the nonces necessary? The current setup in the named targets PR probably does not allow them. Currently the context-matching mechanism is the "sidebar" target name:
    1. The sidebar registers itself as "sidebar" for the current tab with the background script
    2. The content script sends messages to "sidebar"

To do:

@fregante
Copy link
Contributor Author

(Having some trouble debugging this. The messages don't seem to arrive into the iframe even if the tabId and frameId are resolved correctly. Once every 10 times it works. 😰 )

@twschiller
Copy link
Contributor

twschiller commented Oct 20, 2021

The messages don't seem to arrive into the iframe even if the tabId and frameId are resolved correctly

I can help take a look this afternoon. Is this an issue when opening/closing the sidebar, or while the sidebar is open?

Are the messages arriving but then getting discarded for being stale?

For the messaging, I was thinking about investing some time at some point in using a tool like https://bestchai.bitbucket.io/shiviz/ to visualize the communication trace between the components. We could probably instrument the messaging library to produce the format it needs

@fregante
Copy link
Contributor Author

Is this an issue when opening/closing the sidebar, or while the sidebar is open?

I only tried the initial messages at first. It could be that the retries stop too early, but the "named target registered" message happens 3-4 seconds before the last retry.

Are the messages arriving but then getting discarded for being stale?

The raw onMessage handler in the sidebar isn't called, so they don't arrive at all. However, if I later message it manually the messages arrive.

investing some time at some point in using a tool like

That looks good! I can look into it. It might be complicated since there's no "global" communication watcher, so each step would have to probably report back to the background page (via messenger itself) and generate the viz there.

@fregante
Copy link
Contributor Author

I might have found the issue, please don't attempt to debug 😅 it's in pixiebrix/webext-messenger#43

@fregante
Copy link
Contributor Author

This last commit seems to have finally resolved the issue I was having. I will have to keep testing and then clean the PR. ✅ 🥳

Repro for future reference

  1. Open editor
  2. Open sidebar
  3. Click "Save"
  4. See editor error:
    Error fetching remote bricks: No handler for REGISTRY_SYNC was registered in the receiving end
    

Screen Shot 4

if you close the sidebar, it works correctly:

Screen Shot 3

@fregante
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants