greenheartgames / greenworks

a node.js plugin to integrate nw.js/electron games with steamworks
MIT License
1.48k stars 153 forks source link

Electron support #50

Open morgondag opened 9 years ago

morgondag commented 9 years ago

Custom building Greenworks for latest Electron seams to work. Calling greenworks.initAPI() from steam works as intended.

Achievements: The Steam UI is not visible but the achievement is triggered on Steam.

Overlay: No UI or overlay is visible when triggering the API calls, it seams to be unresponsive and not working.

Question: Most of the API calls seams to work but the visual ones. Is there any overlay support for Electron with special workarounds like the nw.js version or is just not supported at this current time? If so, what are the special settings to get it working in Electron? forceRefreshCanvas diden't do the trick.

hokein commented 9 years ago

The game-overlay doesn't work on Electron is a known issue. I have tried it serval times before, but failed. I don't figure out a solution yet. The working solution might be different with nw.js's due to the difference architecture between nw.js and electron. We probably need some help from Electron's community and Valve for making game-overlay works on greenworks.

vaughnroyko commented 8 years ago

Just some additional information here.

electron v0.31.2 is the last version that had the game-overlay working (on Windows only - I don't think game-overlay has ever worked on Mac OS/Linux for electron?). On electron v0.32.0 we can see the functionality broken. Is there an easy way to see what would be effecting this when looking at the diffs between the two? My personal guess is it's something Chromium related?

We seen the same unexpected broken game-overlay functionality on NW.js for Mac OSX support between two versions (mentioned here https://github.com/greenheartgames/greenworks/issues/28) with little connection to it in the changelog/diffs.

srlowe commented 8 years ago

@vaughnroyko This is the changelog between 0.31.2 and 0.32.0. There are probably lots of changes not listed here though.

And here are the commits:

https://github.com/atom/electron/compare/v0.32.0...master

srlowe commented 8 years ago

[Win7 Only] Seems like the problem is that all mouse/keyboard input is dropping through to the underlying browser-window when the steam overlay is open. If I have dev tools open when I trigger the overlay display, then I can still select things and type in the dev tools window in the background.

[EDIT: This describes a problem with win7 and electron 0.34.2, which the in-process-gpu switch fixes]

srlowe commented 8 years ago

So I opened a ticket with electron about this. They responded that it's probably related to chrome, but promptly closed the issue.

We've found that it's possible to get the overlay working on Windows7 (using the method below). However, Windows8 and Windows10 both refuse to display the overlay at all.

Add this to main.js for the Win7 fix:

app.commandLine.appendSwitch('in-process-gpu');

Now I'm trying to figure out what would be different on Win8/10...

hokein commented 8 years ago

@bgSosh Thanks for your work on this.

We've found that it's possible to get the overlay working on Windows7 (using the method below). However, Windows8 and Windows10 both refuse to display the overlay at all.

Does this solution work on all versions of electron or just v0.31.2? I'm wondering whether game-overlay issue on Windows 8/10 is relevant to Steam. Could you try to use the solution described in http://steamcommunity.com/groups/SteamClientBeta/discussions/1/530646080844571939/?

srlowe commented 8 years ago

@hokein In our tests the latest electron (v0.34.2) works properly with Windows7 if that switch is used. I haven't tried other versions yet.

Yeah it crossed my mind too that the difference between 7 and 8/10 could be down to steam itself. I'll try the solution in that thread and report back (though my Win8 is a VM from a fresh image).

srlowe commented 8 years ago

@hokein The solution described in the steam thread had no effect unfortunately.

srlowe commented 8 years ago

Since the electron guys are suggesting that it's probably a chrome change that broke things, it might be interesting to test on NW.js v0.13.0-alpha4 (not alpha5), which is using Chromium45 (same major version as current electron). If there's no problem there, then it would suggest some electron breaking change, rather than chrome/chromium.

framerate commented 8 years ago

Hey guys, I'm working on a project with electron that will lead me to integrate with Steam so this is very relevant to my interests...

Thanks!

vaughnroyko commented 8 years ago

@framerate We are in a situation which isn't ideal, but we are doing what we can in our team. We are about to release a product on Steam with the following situation:

This is the best configuration we could find with what is available currently.

framerate commented 8 years ago

Did you find that > 31.2 didn't work with the overlay at all?

What seems to be the problem that won't allow the overlay on Linux/Mac? Maybe I can help when I get to that point.

vaughnroyko commented 8 years ago

@framerate That is correct. We could not get anything past 31.2 to work with the overlay in all Windows 7/8/10 together. It's been awhile though, I can't quite recall on the Linux/Mac OSX side. It simply did not work trying all sorts of different args/switches - and in some cases with the args/switches, it would crash Electron. My information may be out of date though, I'll reply after trying some of the new Electron builds.

At this point, I'll pay/reward anybody that can get Electron to run the Steam Overlay across all platforms. But I feel it's like a mixture of Steam and Chromium itself and all the money I could offer wouldn't actually get it solved, hah.

framerate commented 8 years ago

@vaughnroyko Thank you, sir. I'll have my electron app running in alpha state this month but it may be a while before I get to integrating in steam. I'm more than happy to try and help when it gets to that point.

I'll watch this thread in the meantime!

marwanhilmi commented 8 years ago

@vaughnroyko @framerate @bgSosh @hokein Sorry to ping everyone but has anyone had any luck getting this to work on Electron? We are trying to integrate payments via Steam in our app and without overlay support, it seems like it is impossible. I've tried various versions of Electron with no luck (hoping to have Windows and OSX support).

Looking on the Steam forums - it doesn't seem Valve is interested at all in supporting Chromium based solutions. What are our options here? Not really sure where to begin trying to solve this problem but we are definitely willing to put up a bounty on this.

vaughnroyko commented 8 years ago

@marwanhilmi Overlay is working once again in the newest Electron on Windows (using a few tricks); however, still no luck on the OSX/Linux side of things, so we are currently using a workaround which involves launching a webpage in their default browser/application on those platforms. Not the best solution obviously, but we are kind of at the mercy of Electron/Valve and I think it's too obscure of a use case for either to pay attention to the issues.

I'll gladly tip/fund anybody that helps fix the issue :)

framerate commented 8 years ago

@vaughnroyko

(using a few tricks);

Could you post those tricks so they're ready when I need them? O.o

marwanhilmi commented 8 years ago

@vaughnroyko You mean Electron 1.2.x?

vaughnroyko commented 8 years ago

@marwanhilmi Yep! Although we haven't tried the latest versions 1.2.x+ as of yet. Hopefully they are still working. We are currently on the release before 1.x but we tried right after and it did work.

@framerate

We use the following switches: in-process-gpu and disable-transparency - although I'm unsure if those still actually have an effect. Can't test at the moment.

As well as two refreshing canvases so the screen is always being updated (a requirement for the Steam overlay). Two single pixel canvases, one in the left top, and one in the bottom right. These are setup in an requestAnimationFrame and just have a clearRect executed on them. We tried using a single canvas that is just the size of the screen, but clearRect is abysmally slow, so the less it clears, the better.

framerate commented 8 years ago

@vaughnroyko My prototype is developed using react and the virtual dom for rendering. Am I understanding that I have to use canvas/double buffering instead for steam?

vaughnroyko commented 8 years ago

@framerate Sorry, should of mentioned. that is just what we needed to do since we don't constantly update/render in our game. If you have a canvas (gpu-enabled css transform stuff works too), that is constantly being updated/re-painted, then you won't need the canvas refreshing trick. All depends on your game I guess.

framerate commented 8 years ago

Hmm. yeah it's just a card game (like Heartstone) but simpler, UI-wise. I only currently update/render when the game state changes. So I'm assuming that's going to be a problem? Or am I misunderstanding?

vaughnroyko commented 8 years ago

@framerate Yep, then you will need to do the canvas trick/fix. Unless you can find another solution.

framerate commented 8 years ago

@vaughnroyko so if I'm understanding, I can just do 2 pixels in the corner of the React-JS UI I have now that constantly refresh and that'll do the trick?

patrickklug commented 8 years ago

We had to the same in Game Dev Tycoon when we show popup windows. Normally the canvas would then stop updating since no animation is playing but the Steam overlay requires a redraw to function. To summarize: You can absolutely use the DOM to do your game but for the Steam overlay to work properly, it's best to add two little canvas elements (as @vaughnroyko described) and refresh them every frame.

I don't think that we use any of the mentioned flags though, so not sure if those are really necessary.

marwanhilmi commented 8 years ago

Just want to update with my results @framerate @vaughnroyko. So far from my testing - it appears the steps you mentioned are required. No luck on OSX but Windows can work.

The window does need to be refreshed on every frame for the overlay to work correctly, it can otherwise get 'stuck' on the screen. Having things like the dev tools open may also cause issues. It also appears just moving or resizing the window will 'unstick' the overlay.

Furthermore, the in-process-gpu flag is definitely required. I've tried various other combinations of settings but no luck without in-process-gpu. I believe Steam can't figure out how to hook into Chromium's GPU process if it is running separately.

Unfortunately, I am having problems with the in-process-gpu flag. On Electron 1.1.x, our WebGL application will completely lock up frequently with the flag enabled. I've had success with Electron 1.2.x on OSX but not able to get 1.2.x working on Windows (Chromium seems to have broken hardware acceleration for me).

Have you guys had any luck with the in-process-gpu flag and noticed any performance / stability issues? I've had difficulty finding documentation on exactly what it does and if there are any alternative solutions.

riadd commented 8 years ago

Has anybody been able to build for Electron 1.3.3, Steamworks 137, Greenworks 0.5.3?

I was able to create the build; at least the npm returns successfully and creates a greenworks-win32.node. When trying to require it in code, the import fails due to a missing module, even though the file is there. I read somewhere that this might be to missing dll files, so I copied the steam sdk dll into the root folder of the electron app. Now the module seems to be found, but I get the a "Devtools was connected from page" error dialogue as soon as I import the module now.

I don't get any output on the console, now on the command line. I have no idea how to proceed at the moment. If somebody could maybe upload the .node file for the mentioned release configuration that would be great as it would allow me to check if the error is on my end or not. Also any comments welcome.

hokein commented 8 years ago

@riadd, could you try to use the prebuilt greenworks binary v0.6.0 for electron? It works fine for me on electron v1.3.3 ia32 on windows.

riadd commented 8 years ago

@hokein Thanks again. The prebuilt binary works, at least I'm not getting a crash anymore and the module can be imported properly. I'm still unsuccessful at bringing up the overlay though when starting the game through steam. I have a canvas that is drawn in every frame, so that shouldn't be the problem.

riadd commented 8 years ago

@marwanhilmi How do you apply the --in-process-gpu flag? Just adding it via command line or through a config file as with nw.js?

riadd commented 8 years ago

@hokein @marwanhilmi It works after adding

app.commandLine.appendSwitch('in-process-gpu')

Thank you! I will report back in case of performance issues after some further testing and distributing the update to our 30,000+ players ;)

marwanhilmi commented 8 years ago

@riadd Just a heads up - we have only been able to get the overlay to work on Windows 8 to 10. No luck on Windows 7 or macOS. The overlay works on Windows 7 but it is extremely unstable and frequently does not boot correctly.

See here for docs on app.commandLine.appendSwitch : https://github.com/electron/electron/blob/master/docs/api/app.md#appcommandlineappendswitchswitch-value

marwanhilmi commented 8 years ago

Looks like you found it :)

vaughnroyko commented 8 years ago

Unfortunately Windows 7 no longer plays nicely with the Steam overlay with "in-process-gpu" set and will routinely crash. We tracked this down to a Steam-specific issue, but it's unlikely we'll ever get a fix since Valve technically does not support overlay functionality with any Chromium-based game.

So basically, Windows 8/10 are the only two platforms where we can get Steam overlay support with Electron currently. I assume it's a similar situation with NW.js.

marwanhilmi commented 8 years ago

@vaughnroyko This is exactly what we encountered on Electron 1.2.3 on Windows 7 - for us, it does not seem to crash but it fails to boot all together and will routinely get stuck booting as a zombie process. Checking Steam overlay logs shows something like Failed to hook into process (can't remember exact message) and hangs forever.

I'm assuming the Windows 8 / 10 work differently because of newer DirectX integration. We sent logs of the error to Steam but doubtful it will be fixed. We just disabled in-process-gpu and overlay all together for Windows 7 and show a dialog message if the user hits Shift-Tab.

Did you discover anything else?

We are considering bumping to Electron 1.3.3 as we are noticing GPU related performance issues with 1.2.3.

hokein commented 8 years ago

@marwanhilmi @vaughnroyko @riadd Thanks for sharing the experience and results! Is anyone willing to add some documents/conclusions about these Electron game-overlay stuff in the troubleshooting? It would be really helpful to other Electron-based game developers.

marwanhilmi commented 8 years ago

Sure, can do. I'll send over a PR.

riadd commented 8 years ago

@vaughnroyko @marwanhilmi Thanks for the warning regarding OS stability. I'll try this for now:

var os = require('os');
if (os.platform() === 'win32' && parseInt(os.release().split('.')[0]) >= 8) {
  app.commandLine.appendSwitch('in-process-gpu')
}
hokein commented 8 years ago

@vaughnroyko, @bgSosh, @morgondag, @framerate, and developers who are using electron,

If your game is released in Steam, could you please add your game to our product list to let more people know? I'd appreciate it.

framerate commented 8 years ago

Our alpha is almost done so I'll be investigating Steam soon!

On Sun, Sep 4, 2016, 7:34 AM Haojian Wu notifications@github.com wrote:

@vaughnroyko https://github.com/vaughnroyko, @bgSosh https://github.com/bgSosh, @morgondag https://github.com/morgondag, @framerate https://github.com/framerate, and developers who are using electron,

If your game is released in Steam, could you please add your game to our product list https://github.com/greenheartgames/greenworks/wiki/Apps-games-using-greenworks to let more people know? I'd appreciate it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/greenheartgames/greenworks/issues/50#issuecomment-244606815, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEiM3tSjxl-L-QsgIzIDi_BWtAM-uwRks5qmtblgaJpZM4F-XcP .

riadd commented 8 years ago

I've had to switch back to nw.js due to sound issues/glitches with the current Electron version, but I added our project to the list.

framerate commented 8 years ago

Also, any of you guys at PAX West? I'd love to meet fellow electron game dev!

marwanhilmi commented 8 years ago

I'm not there myself but look for the Duelyst team!

On Sep 4, 2016 12:10 PM, "Justin Reynard" notifications@github.com wrote:

Also, any of you guys at PAX West? I'd love to meet fellow electron game dev!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/greenheartgames/greenworks/issues/50#issuecomment-244612007, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYCNIUZR7gU5swWbewRK3wWAxfqwHb3ks5qmu2GgaJpZM4F-XcP .

vaughnroyko commented 8 years ago

@hokein Added Wayward to the list!

michaelpelletier commented 7 years ago

Any updates on this from anyone? Electron 1.5 is in Beta and upgrades Chrome to 54 - is there any reason to suggest that might help? Been trying to find a solution to this bug for what feels like years. :(

goldfire commented 7 years ago

I've been reading through all of these issues and am unclear on what the current state is. Am I right in assuming that there is still no way to get this to work on Mac/Linux, but that it should work on at least Windows 8/10 (for example, for the payment overlay)?

framerate commented 7 years ago

I've been reading through all of these issues and am unclear on what the current state is

I'm in the same boat! I plan on taking a deeper look later this year and would love to know what the status is!

morgondag commented 7 years ago

Well we have a electron build up for mac and linux, But its like 8 months old now. no steam overlay. no achievements on linux stuff like that. The most time consuming thing is to figure out what magical secret combo of electron/nw.js greenworks steamAPI works together, if you anyone got the secret formula feel free to post 👍

treeform commented 7 years ago

I managed to get it to work about a year ago, but when I tried to update everything broke. So I reverted my update and run old electron + old greenworks + old steam dll. Here is what I run:

greenworks-v0.7.0 electron-v1.4.0 steamsdk: v1.36 9th February 2016

Works on mac, windows and linux.

One one hand running such outdated versions feels bad, on the other hand if it works it works...?

jhovgaard commented 7 years ago

Struggling with this too.