Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Conversation

asturur
Copy link
Contributor

@asturur asturur commented Mar 19, 2021

Identify the Bug

The upgrade to electron 9.4.4. broke the context menu click.
The issue is tracked in #22018

The stack trace point to the fact that they payload for the message is no more serializable
The change in the api that broke the code should be this:
https://www.electronjs.org/docs/breaking-changes#behavior-changed-values-sent-over-ipc-are-now-serialized-with-structured-clone-algorithm

Description of the Change

My fix was to remove the reference to atomWindow from the payload, the part that is not serializable.

Alternate Designs

There is also this other fix here that i noticed after making this one:
#22046

Possible Drawbacks

Well a value removed from the payload can of course have drawbacks.
I have no understanding why we are sending a reference to the window in the payload if we are sending the message to that exact same window.

Does anyone knows why that is needed?
The window is probably a large object and serializing it won't let the instance itself travel with the message, but it should become just a bunch of data.

Verification Process

The only verification process is me trying the right click menu on my local build on macosx and the PR tests

Release Notes

  • fixes right click menu on atom with electron 9+

@rwad784
Copy link

rwad784 commented Mar 19, 2021

@asturur
Copy link
Contributor Author

asturur commented Mar 19, 2021

@sadick254 you have any idea what we do with that command detail there?

@asturur
Copy link
Contributor Author

asturur commented Mar 22, 2021

hi @darangi, i see we have a fix and we can close this PR now.
I was looking into insight of what we do with this extra command detail in the message.
Any information you can give?

@aminya
Copy link
Contributor

aminya commented Mar 22, 2021

Doesn't this fix #22024 by coincidence?

@asturur
Copy link
Contributor Author

asturur commented Mar 22, 2021

Not sure.
The issue was atomWindow property not being serializable under electron 8, Atom stop running the right click command event, and not complaining about it at all.

If some of those issue are stopping Atom to complete the tests, yes this pr ( and the merged one ) could have already fixed it.

My solution was to remove it, since everything was working without it.
@darangi solution was to serialize it with structured clone library, but i would love to understand what atom is doing with that property. Because i could not find a use for it.

@asturur
Copy link
Contributor Author

asturur commented Mar 24, 2021

Still interested in the topic :D anyone available?

@aminya
Copy link
Contributor

aminya commented Mar 24, 2021

Is item.commandDetail.atomWindow used anywhere else in the code?

@asturur
Copy link
Contributor Author

asturur commented Mar 24, 2021

That is what i was trying to look into. Is not used in atom codebase at all, not with a full text search at least.
I understand the fix we merged for the menu is safer, but it also add a new dependency to the project ( for how much is small ) and to me this seems like the moment to look into it. From git blame it was added in 2014
9128041

But i m not sure how that value is used since the atomWindow is serialized and not more a reference to the original window.

I compiled the version with this commit 5 days ago and i m using it waiting for the fixed nightly to come out.

@sadick254 or @darangi do you have any insight?

@sadick254
Copy link
Contributor

@asturur item.commandDetail.atomWindow is not used anywhere in the codebase but passed around and sent as args to the receiver of the context-command action. https://github.com/atom/atom/blob/master/src/main-process/atom-window.js#L378

Since the context menu has already been fixed can we safely close this?

@asturur
Copy link
Contributor Author

asturur commented Mar 25, 2021

i know is passed down, but if you look at the command, those are just strings and do not seems to use the reference to a copied version of the atomWindow anywhere.
What data is in the atom window we need for the context menu to work?
I do not mind about the PR we can close it, i mind about the conversation if is possible.

  • is it used by the plugins ?
  • is this a part of the api exposed ouside atom or is just internal?
  • was preserving this property the best thing to do?
  • is a serialized version of the instance useful at all?

If we can ditch the property and not add a dependency, isn't better?

@sadick254
Copy link
Contributor

I have done a little bit of digging into the source code. I can't see anywhere where we use the passed atomWindow reference. Removing atomWindow would be ideal as the serialized version isn't useful at all.

Right now we have a failing CI due to the first context menu fix. Could you include a revert commit of that change on this branch?

@asturur
Copy link
Contributor Author

asturur commented Mar 29, 2021

Sure i think i can. I got a failing build too and i fixed with the second commit. I ll update it tomorrow early for me

@UziTech UziTech mentioned this pull request Mar 30, 2021
7 tasks
@asturur
Copy link
Contributor Author

asturur commented Mar 30, 2021

Seems like now this PR is affected by timeouts in windows

@darangi
Copy link
Contributor

darangi commented Mar 30, 2021

Seems like now this PR is affected by timeouts in windows

Yeah, a CI re-run will resolve that CI is ✅

@darangi
Copy link
Contributor

darangi commented Mar 30, 2021

Thanks for the contribution 🙇🏾 @asturur

@darangi darangi merged commit 4d2d9c8 into atom:master Mar 30, 2021
@aminya
Copy link
Contributor

aminya commented Mar 30, 2021

@asturur Thanks for your perseverance on the topic. This kind of non-trivial contribution is very interesting and valuable!

@asturur
Copy link
Contributor Author

asturur commented Mar 30, 2021

i stubbornly use atom while evetyone tells me to switch to vscode. I m happy to help and to learn electron.js

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

Successfully merging this pull request may close these issues.

5 participants