Git Product home page Git Product logo

Comments (18)

mkaemmerer avatar mkaemmerer commented on June 2, 2024 1

Summary/status-update:

I can get steamworks.js to run correctly in development mode in my own project, but not when building it into a ".app" package. I can get steamworks.js to build and run as a ".app" using the example project. The primary difference seems to be the way the projects are built. I did some tests to try to build the example project using other build tools. I was unsuccessful.

  • electron-packager ✅
  • electron-builder ❌
  • electron forge 1

I don't particularly want to migrate my project to use electron-packager, but I'm not seeing a lot of other options at the moment.


1 In addition to my own tests, I found an issue about it in the electron forge repo -- electron/forge#3193

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

There's an example test electron project checked into this repository, in the test/electron directory.

The easiest way to test it is to copy the entire test/electron folder to a separate directory outside the repository, and edit package.json, changing the line "steamworks.js": "../.." to "steamworks.js": "0.3.0". Run npm install in the electron folder, and then launch the Steam client app, and then npm start.

(Note that you do have to launch the Steam client app yourself manually before launching the Electron app; the Steamworks API is designed to communicate with the Steam client app process to do its work.)

On my macOS Ventura 13.4.1 machine, the test Electron app launches without error and displays my Steam user name in the UI of the Electron app.

Note what I didn't have to do: I didn't have to include my own copy of the .dylib (because steamworks.js provides its own copy), and I didn't have to create a steam_appid.txt file, because renderer.js hardcodes a Steam App ID as app ID 480, which is the App ID of Steam's example game, SpaceWar.

If the example works for you, you should be able to make small changes to the project, e.g. change 480 in renderer.js to your own App ID, run other steamworks.js methods, etc.

If it doesn't work for you, you could try building steamworks.js from scratch and then running the test electron project from inside the Git repo. Just npm install and then npm run build in the root, then cd test/electron and npm install and npm start. It's supposed to work.

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

Hi @dfabulich, I'm @chostett's collaborator -- thanks for pointing us in the right direction ! I was able to run the example project successfully, and include my own App ID.

Another big step forward is that I was able to successfully initialize steamworks.js in our project, but only when running in development mode. Unfortunately the error persists in the production build. Made note of some notable differences in our project compared to the example, perhaps one of these is to blame:

  • build with electron-builder instead of electron-packager
  • using an older version of electron
  • initialize steamworks.js from the main process instead of the renderer process

I currently suspect the issue lies with electron-builder. I'll try to keep this thread up-to-date in case anyone else is experiencing the same issue.

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

Update: ran some experiments, and yep... it looks like an electron-builder issue. I could successfully build and run the example after moving the init to the main process, and after downgrading electron. On the other hand, the example crashes when I build it using electron-builder.

Minimal repro -- use the code in the example directory, change the package.json to this:

{
  "name": "steamworks.js-electron-test",
  "author": "(author and version fields required for electron-builder)",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "steamworks.js": "^0.3.0"
  },
  "devDependencies": {
    "electron": "24.2.0",
    "electron-builder": "24.6.3"
  },
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder -m"
  },
  "build": {
    "mac": {
      "target": "zip"
    }
  }
}

Result is that the application crashes with a segfault immediately on launch, then OS X pops up an error-reporting modal "steamworks.js-electron-test quit unexpectedly."

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

Why are you initializing steamworks from the main process? Steamworks wants access to the UI, so initializing in the renderer is probably best, following the example project.

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

@dfabulich - my project is using "contextIsolation" from the browser window, so I handle the calls to steamworks using IPC. I wanted to check to find out whether that makes a difference (in terms of whether or not the application crashes).

Turns out it doesn't. Whether steamworks is called from "main" or from "renderer" -- either way, the example crashes if I build it with electron-builder instead of electron-packager.

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

I use electron-builder myself. I run it like this:

electron-builder --x64 --win dir --linux dir --mac dir

I just tried it with electron-builder 24.6.3, electron 25.3.2, and initializing steamworks in the renderer. Didn't crash for me.

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

I still haven't found a compatible combination of versions and invocations. The latest thing I've tried is:

  • electron 25.3.2
  • electron-builder 24.6.3
  • steamworks.js 0.3.0

Using the code from the example app. Build with this command:

electron-builder --x64 --mac dir

The resulting .app bundle does not segfault, but it doesn't render HTML or connect to Steam either. The application window shows a blank page with no text in it.

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

Does it render HTML when you rip out Steamworks?

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

If I remove steamworks completely then yes, the application renders as expected.

There are two points in the example code that call require('steamworks.js').

  • (A) the main process, which calls steamworks.electronEnableSteamOverlay()
  • (B) the renderer script, which callssteamworks.init(...), client.localplayer.getName(), client.overlay.activateToWebPage(...)

I ran a couple other experiments. Here were the results I got:

  • remove A and B --> app renders html
  • remove only A --> app does not render html
  • remove only B --> app renders html

I suspect the issue lies in the init call, but there's no logging in the example app and I haven't added any yet, so I can't say for sure.

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

Are you calling activateToWebPage() on load? That can't be right. Try getting rid of that? (The Steam overlay is very finicky.)

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

Are you calling activateToWebPage() on load? That can't be right. Try getting rid of that? (The Steam overlay is very finicky.)

No, I never call it on load. It's called in the button event handler

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

One of the hardest things about steamworks.js is that sometimes people write in, saying, "it doesn't work on my machine," without providing detailed steps to allow others to reproduce their work. For example, in this case, you sent us package.json and a written description of your main/renderer, instead of a repository that demonstrates the error.

Your electron-builder package.json works great on my machine, using main.js, renderer.js, and index.html from the test/electron folder. I've filed a PR #115 to add an electron-builder sample to this repository; not sure how @ceifa will feel about it.

When I check out that branch, build steamworks.js, and npm run start in the electron-builder directory, it works, and shows my Steam user name. When i npm run dist, it generates an app in dist/mac-arm64. When I double-click it, it opens, and shows my Steam user name.

Does my electron-builder sample work on your machine? I've shipped dozens of Steam apps using steamworks.js using electron-builder. I'm certain in works.

If you'd like to make a similar PR for electron-forge, I can try that on my machine, too. (I've never used Forge, though.)

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

@dfabulich - thank you for the reproducible example!

Unfortunately, the problem persists. Here are the steps I followed.

  1. Clone the repo - https://github.com/dfabulich/steamworks.js.git
  2. Check out the electron-builder branch
  3. cd ./test/electron-builder
  4. Install dependencies with npm install

First attempt

  • run npm start
    • ❌ error "Can't find dist/osx/steamworksjs.darwin-x64.node". Oh I see, I have to build the rust package first because the dist/ directory isn't part of the source code... trying again.
  • run npm install and npm build from project root.

Second attempt

  • npm start
    • ✅ app launches and connects to steam.
  • npm run dist
    • generates an app in dist/mac (NOT dist/mac-arm64 -- I'm building on a 2017 Intel i5 Macbook)
    • ❌ no errors, but the app launches to a blank screen. HTML does not load.

from steamworks.js.

mkaemmerer avatar mkaemmerer commented on June 2, 2024

UPDATE:

Third attempt: explicitly disable code-signing in electron-builder

  • npm run dist -- -c.mac.identity=null
    • generates an app in dist/mac
    • ✅ app launches and shows steam username

By default, electron-builder was code-signing using my keychain. From https://www.electron.build/code-signing.html

On a macOS development machine, a valid and appropriate identity from your keychain will be automatically used.

This feels like huge progress, but still leaves the open question: "How do I use steamworks.js if I want to ship a signed, notarized mac app?"

from steamworks.js.

dfabulich avatar dfabulich commented on June 2, 2024

Notarization works fine on ARM64, but fails on x86_64. See #103 and #114.

from steamworks.js.

ceifa avatar ceifa commented on June 2, 2024

@mkaemmerer can you check if the error still persists on latest version?

from steamworks.js.

x1911 avatar x1911 commented on June 2, 2024

electron-builder --mac -c.mac.identity=null

this one works for me, but it shows error after uploaded to steam

from steamworks.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.