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

Windows does not display Notifications #4973

Closed
kumpelblase2 opened this issue Mar 31, 2016 · 27 comments · Fixed by electron-archive/brightray#214
Closed

Windows does not display Notifications #4973

kumpelblase2 opened this issue Mar 31, 2016 · 27 comments · Fixed by electron-archive/brightray#214
Assignees

Comments

@kumpelblase2
Copy link

  • Electron version: 0.37.3
  • Operating system: Windows 10 Build 10586.104

I've been trying to figure out if I'm missing something or anything, but since the docs only state that they "just work" on windows 10 I'm at a loss here. Notifications show fine for osx and linux, just not on windows 10. I can even go into the devtools and type new Notification("testing", { body: "testing" }); and nothing happens. Do I need to make an installer or do I have to set the application user model id? Or might the packager screw it up?

EDIT: I can rule out the packager, just did an npm install with electron-prebuilt 0.37.3 -> ran electron main.js -> created a new notification in devtools and no avail.

I can reproduce this with the electron-quick-start example app using the version set in package.json (^0.36.0) or setting it to 0.37.3.

@felixrieseberg felixrieseberg changed the title Windows 10 does not display Notifications Windows does not display Notifications Mar 31, 2016
@felixrieseberg
Copy link
Member

I think we're dealing with a regression here, across all Windows versions. I see that @zcbenz fixed something in 0.37.2 to re-enable notifications on OS X and Linux, I'll take a look to see what the bug with Windows is.

@felixrieseberg
Copy link
Member

...actually, quick update: You're not the only one reporting this, but after firing up my little matrix over here, I can't reproduce the issue with any of the later Windows 10 builds using both 37.3 and 36.12.

Could you ensure that notifications are not disabled? They fail silently if they are.

@felixrieseberg felixrieseberg added blocked/need-info ❌ Cannot proceed without more information and removed bug labels Mar 31, 2016
@kumpelblase2
Copy link
Author

Yes, as far as I'm concerned, they're all on. Screenshot
I've tested it inside a VM using the latest ISO from the Microsoft website, so no settings have really been changed. I've also updated to latest build (10586.164) but to no avail. Maybe because I haven't inserted activation code yet?

@mccxiv
Copy link

mccxiv commented Apr 1, 2016

I'm on a Windows 10 machine, running new Notification("testing", { body: "testing" }); in devtools does not display a notification. Balloon notifications done via the Tray module work fine.

Using 0.37.3 from npm i electron-prebuilt

@felixrieseberg
Copy link
Member

Let me try a fresh Windows image tomorrow, maybe we're setting some settings with older versions of electron that are we're not setting in the new ones.

In the meantime, could you give an older electron build a try? If it works in 36.10 (or so), we'd know for sure that it's a regression.

@kumpelblase2
Copy link
Author

I can confirm that they do work in 0.36.10 and 0.36.11, but not in 0.36.12. So this does indeed seem to be a regression.

EDIT: they also do not work in 0.37.1, yet work in 0.37.2, but again not in 0.37.3.

@torhve
Copy link

torhve commented Apr 1, 2016

Can confirm this. Works in older, does not work in newer.

@felixrieseberg
Copy link
Member

And just to make things worse, it seems like that running an older version of electron and sending a notification "fixes" the new versions. We're probably not setting something that we used to set - I'll get on it.

@felixrieseberg
Copy link
Member

Doing some breakpoint debugging, I have no clue what change is responsible. @zcbenz: Any idea what could have disabled notifications?

Maybe any changes around the AppModelId?

@javan
Copy link
Contributor

javan commented Apr 1, 2016

Confirmed here too. Notification.permission returns "granted", but no notification is displayed after constructing one.

75ec7a0 looks like it might be the cause. Points to electron-archive/brightray@242feb1.

@felixrieseberg
Copy link
Member

Nah, that was me - and that checked is passed, but the notification still doesn't display.

@javan
Copy link
Contributor

javan commented Apr 1, 2016

Dug some more, now I think #4805 may be the cause. To test, I cloned the electron-quickstart-app, bumped electron-prebuilt to 0.37.3, and added a new Notification to index.html. The notification displayed normally. Then I added a call to app.setAppUserModelId in main.js and notifications stopped working.

@zhenchaoli
Copy link

can confirm this happens on 0.37.3 and 0.37.5..
however for me, notification works for packaged app. As soon as it's turned into a installer and installed on my system, notification stops working, even creating a Notification object in the console does not work.

Also building with and without #4805 confirms the regression is introduced ini the commit..

Ah implementing notification on Windows is so much more complicated than on Mac.. Really appreciate your efforts working on it!

@felixrieseberg
Copy link
Member

Quick update: Setting any app user model id does indeed break notifications. However, that is not the case for Electron 0.36, so I assume that there's actually something else going on here.

@felixrieseberg
Copy link
Member

So, after hours of debugging: I'm not entirely sure what the actual reason is. Sometimes I get notifications, sometimes I don't. If somebody can reliably reproduce this, I'd love to know all the system details.

@zhenchaoli
Copy link

I could never get notification on win 10 with the userAppModelId change.

@javan
Copy link
Contributor

javan commented Apr 8, 2016

Here's a sample app that I can reproduce the issue reliably with: https://gist.github.com/javan/4dd6990cf7756cdff81eca62896bbb98

Tested on a Windows 10 VM from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/mac/ running in VMWare Fusion. Details:

Host Name:                 MSEDGEWIN10
OS Name:                   Microsoft Windows 10 Enterprise Evaluation
OS Version:                10.0.10240 N/A Build 10240
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:
Registered Organization:   Microsoft
Product ID:                00329-20000-00001-AA421
Original Install Date:     9/25/2015, 7:44:42 AM
System Boot Time:          4/5/2016, 12:12:55 PM
System Manufacturer:       VMware, Inc.
System Model:              VMware Virtual Platform
System Type:               x64-based PC

Run it as-is and Notifications should appear. Then uncomment setAppUserModelId() in main.js and run again. No notifications.

notifications-no-appid

notifications-appid

Sometimes I get notifications, sometimes I don't.

I found that after I dropped down to 0.36 and then back up to 0.37, I couldn't reproduce until I changed the appUserModelId string to something different. Seems like Windows liked and remembered whatever 0.36 did and continued to like it on 0.37.

Hope this helps!

@felixrieseberg
Copy link
Member

One more update: I spent hours (about 20) at this point in ProcMon, ProcExp, and windbg - and I still don't know what the exact root cause of the issue is. The symptom is clear: Once the app user model id is set (and it is set correctly), the app receives NotificationSetting 2 (DisabledForUser).

However, I do find it interesting that in #4842, breakpoints set with 0.36.x work in 0.37.x, while breakpoints set in 0.37.x do not. I'm sort of expecting that this will be fixed by a seemingly random change somewhere else.

@zcbenz @paulcbetts: Any ideas? If anyone has any ideas left, it's probably you two.

@anaisbetts
Copy link
Contributor

@javan I'm not sure that this repro makes any sense, because you're not launching the executable from a shortcut with an app user model ID set - if you're just running Electron, you shouldn't set your app user model ID

@felixrieseberg
Copy link
Member

On Windows 10, you actually don't need the shortcut for notifications.

@javan
Copy link
Contributor

javan commented Apr 12, 2016

@felixrieseberg, thanks for all your time on this! ❤️ Sounds incredibly frustrating to debug. v0.37.0 upgraded to Chrome 49 and Chrome seems to have movement around native notifications. I don't have specific Chrome changes to point to, but I wonder if there's some kind of conflict.

For the sake of moving forward, what do you think about scoping the changes in #4805 to Windows < 10 to get notifications working in Win 10 at least?

@dmythro
Copy link

dmythro commented Apr 12, 2016

Our team checked on different PCs, on some Windows 10 it works, on some - not. On Windows 8/8.1 doesn't work (as worked before) at all. But when we completed the task with Electron v0.37.3 all was fine - so maybe the problem comes with Windows updates as well.

As for the recent builds of Windows 10 we got this:
Electron v0.37.5 - x86 works, x64 doesn't work
Electron v0.37.2 - x86 works, x64 works

Would be glad to help more with it, but don't work with native development for years.

@zcbenz
Copy link
Contributor

zcbenz commented Apr 15, 2016

After biset the commits, I can confirm this is caused by electron-archive/brightray@242feb1. The key of debugging is, make sure you change the AppUserModelID to a new value every time, otherwise Windows itself might be confused and give random results.

@zcbenz
Copy link
Contributor

zcbenz commented Apr 15, 2016

The problem seems to be:

  • When AppUserModelID is set:
    • when using AppUserModelID as notifier's ID, notification settings would say notification is disabled;
    • while using application name as notifier's ID, everything works.
  • When AppUserModelID is not set:
    • notification works no matter what we set as notifier's ID.

@felixrieseberg
Copy link
Member

Man, thanks a lot. I'll buy you a drink next week.

In the meantime, I'll confirm on our machines and then send a PR!

@zcbenz
Copy link
Contributor

zcbenz commented Apr 15, 2016

while using application name as notifier's ID, everything works.

Hmm I'm wrong here, when using application name as notifier's ID, it is actually telling Windows our AppUserModelID is the application name, which works because it has been used as AppUserModelID by old versions of Electron before.

The magic thing is, if we ignore get_Setting and send a notification anyway, the notification will show and following notifications with the same AppUserModelID will also work. But if we check get_Setting in the first time, it will always return DISABLED.

@Praveer1981
Copy link

@javan @felixrieseberg
Since we had upgraded electron version to 7. the notification stopped working. is it a known issue.

#22061

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

Successfully merging a pull request may close this issue.