-
Notifications
You must be signed in to change notification settings - Fork 107
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
Electron ipcRenderer.sendSync() with 'is-mutation-observer-enabled' channel without listeners. #2437
Comments
Hi @kylegundersen, Thanks for reaching out. This The code that sets this listener is here: https://github.com/ghostery/adblocker/blob/master/packages/adblocker-electron/adblocker.ts#L87 And the code that removes it is here: https://github.com/ghostery/adblocker/blob/master/packages/adblocker-electron/adblocker.ts#L113 In principle, on unload we also remove the preload script so there should not be any such message sent after the unload. |
Thanks @remusao for the quick and detailed reply and all the work yo do on this open source masterpiece. FYI I am running the latest version of Electron. I am not sure if this issue would be considered closed, I just kind of danced around it with the conditional. Is there any disadvantage to just removing line 113 that removes that listener? (Assumptions: If I am not mistaken it will get overwritten anyways if a new one is spawned with the same channel name, and I am pretty sure they don't tie up much resources.) |
If you do so, you will disable part of the adblocking capability. Everything but the network blocking code, which might not be desirable.
Thank you very much for the kind words. Regarding your last remark, I am not sure how removing the line would solve the warning you observed. Do you have some minimum test case to reproduce the issue? Is it consistently happening when disabling blocking? |
Ad-blocker-freeze-example.zip You will notice this is a very simple Electron project and it does happen every time.
Thanks, hopefully this helps. |
I investigated it more thoroughly this morning. So the issue is that the event Two possible solutions:
Let me know your thoughts? |
Thanks for investigating. I do not understand why the preload script is not removed when the adblocker is disabled? My understanding is that the call to disable blocking in session should also remove the custom preload script, which means the |
Yea I checked the code and it seems to give me the expected session.preload value, but your right it doesn't seem to update what is happening within the currently running webContents. I wonder if we should escalate to the Electron team. At least they can confirm if this is expected behavior or if there an issue. |
Good idea, it is not clear to me if this is a new behavior because at the time this code was written I am pretty sure it was pretty extensively tested. Maybe @sentialx has some insight into this behavior. Do you remember if disabling blocking was also impacting existing preload scripts? @kylegundersen What I find weird is that even if the existing preload script are still running, the |
@remusao I performed a |
@remusao this library is broken for Electron as of now, do you want me to PR the removal of that line until someone has time to look into this deeper? |
If you have a partial fix then yes. So the quick fix is to never remove the listener so that we do not get the error right? Since I am not actively using the adblocker in electron I would appreciate some help if you have time to get to the bottom of this. I'm happy to help. @sentialx Is it also broken for your project? (If you are still using the library) |
Yes that is the only way in my mind. We could change send to |
This is still not so clear to me why removing the preload script is not enough. In all the existing frames where the preload script was already injected then the event should have been fired already, and all new frames should not get the preload script after disableBlockingInSession is called. So why do we still have preload script trying to send this sync event after the unload? |
@remusao yea its not clear to me either, I can only speculate that there could be some caching going on behind the scenes. The more I think about it , not removing that listener is probably the best long-term solution. Unsubscribing from any |
@remusao Sorry, I no longer use Electron for my browser. I didn't really use |
Thank you for taking the time to comment here @sentialx. |
I have found that if you start with enableBlockingInSession using the default session. Then you try to disable those Ads using disableBlockingInSession. It will throw an error and make any associated webContents become unable to receive input.
WebContents #24 (which is the ID) called ipcRenderer.sendSync() with 'is-mutation-observer-enabled' channel without listeners.
Seems that there is no listener present, I am not 100% sure for what is-mutation-observer-enabled is used for considering it looks to be a one-time configuration. (didn't have time to dig for that long.)
By removing it from the preload script everything works as expected.
My question is what is the use case for is-mutation-observer-enabled?
The text was updated successfully, but these errors were encountered: