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

Don't send messages to destroyed webContents #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ibash
Copy link

@ibash ibash commented Jan 31, 2018

This commit:

  1. Prevents sending messages to destroyed webContents (which result in a crash)
  2. Allows registering multiple webContents for push notifications

We need this because we are listening for notifcations in a specific
webContents. If it crashes we create a new one and call setup again,
without this change the next push notification that came in would cause
a crash.

This commit:
1. Prevents sending messages to destroyed webContents (which result in a crash)
2. Allows registering multiple webContents for push notifications

We need this because we are listening for notifcations in a specific
webContents. If it crashes we create a new one and call setup again,
without this change the next push notification that came in would cause
a crash.
@ibash
Copy link
Author

ibash commented Jan 31, 2018

cc @MatthieuLemoine I tried to make the minimal change to make this work, but I think I'd like to do some refactoring later on to make it s.t. each call to setup is isolated from one another, what do you think?

That seems to be crashing the app ref: electron/electron#11797
@ibash
Copy link
Author

ibash commented Feb 1, 2018

Hit a weird electron crash, so I removed the call to isDestroyed: electron/electron#11797

webContents.send(NOTIFICATION_SERVICE_ERROR, e.message);
// Forward error to the renderer processes
send(NOTIFICATION_SERVICE_ERROR, e.message);
starting = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starting is never set to false if no error is thrown. Is it intended ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - in that case started should be true, so it would return around line 44 anyway.

@ibash
Copy link
Author

ibash commented Feb 1, 2018

Hey it seems like the crash I was experiencing might be unrelated to this project, doing some more digging now...

@ibash
Copy link
Author

ibash commented Feb 2, 2018

Okay - the other crash I was getting was electron/electron#11797 I think this change is still needed to prevent the main process from crashing when the webContents that's setup to receive notifications crashes...

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