ElectronJS Kiosk not saving cookies

I’m building an application that requires a kiosk and have moved on from chromium in search of something light, minimal and most importantly allows accelerated gpu. Oh! And supports video autoplay. This is why I don’t just use the wonderful WPE browser you guys use in your balenaDash project.

So I’m running the Electron kiosk and I need to store cookies. The problem is that I don’t know where they are stored. I’d like to find that out and then claim that as a volume in my docker compose unless there’s a better way of doing this. This is the solution I used for the chromium browser:

The reason for needing to save cookies is that they’re used for authentification.

hey @KingstonSteele
You will have to find the location of the user data. perhaps this will help : https://stackoverflow.com/questions/43912928/where-an-electron-applications-sessionstorage-and-localstorage-stored

Also, you could maybe save cookies on exit and load on start using the electron cookies api: https://www.electronjs.org/docs/api/cookies

Hope this helps.
Out of curiosity, since i’m working on trying to get hardware accleration for video decoding using electron on pi, have you been able to do this? if so can you please share how? fyi, I have been able to get gpu acceleration, and autoplay using chromium. see this WIP repo: https://github.com/balena-io-playground/chromium-ha

thanks

Nice I’ll have to take a look at that project.

“Also, you could maybe save cookies on exit and load on start using the electron cookies api.”

Yes it seems that I may need to do that in addition to creating a volume so that cookies are saved on restart.

“Out of curiosity, since i’m working on trying to get hardware acceleration for video decoding using electron on pi, have you been able to do this?”

I haven’t gotten that far yet, that’s concerning to hear. Without acceleration for video, that negates the need for switching to electronjs.

How long have you been working on the electron kiosk?

Thanks!

I have recently started looking into electron for kiosk. So hope you get it to work!
Do you have any experience in compiling electron from source?

I don’t have experience building from source but I’d love to work together to figure out this hardware acceleration issue.

Here is my fix for cookie storage.:

version: '2'
volumes:
    userData:
services:
  gui:
    restart: always
    build: ./gui
    privileged: true
    volumes:
      - 'userData:/usr/src/app/userData'

It seems though, that you’re correct in that there seems to be no hardware acceleration. Maybe this could be something we can tag team?

And this for an environment variable:

ELECTRON_USER_DATA_DIR=/usr/src/app/userData

hey @KingstonSteele

I’m not too familiar with building electron from source too. It might not be required too(let’s hope so).

My guess as to why the hardware acceleration is not working is because the raspberry pi foundation does some custom modifications to the chromium browser they provide. You can see the patches here (https://github.com/RPi-Distro/chromium-browser/tree/master/debian/patches). So I assume the electron chromium engine lack those changes since the upstream patches for electron are here ( https://github.com/electron/electron/tree/master/patches/chromium)

hopefully adding the raspberry pi specific patches to electron and then compiling it will get the hardware acceleration working. You can find the instructions for building it on linux here. If you can give it a try that would be very helpful!
Let us know how it goes.
Cheers!

I’m working on using the “supported” hardware acceleration solution by installing the needed packages but this is a quick solution which does work, especially for video. It’s a in the fleet configurations dtoverlay:

RESIN_HOST_CONFIG_dtoverlay=vc4-fkms-v3d

That alone helped quite noticeably.

Which Pi are you using? That is enabled by default on the Pi4.
Can you confirm you have hardware accelerated video decode? If you can look at the output from chrome://media-internals from a separate tab while video is playing. and check the video_decoder field: if it is Hardware accelerated it usually says mmalVideoDecoder and if In-software decoding -VpxVideoDecoder, FFmpegVideoDecoder. Do you mind sharing your Dockerfile please? are you using the flags such as --ignore-gpu-blacklist?

I’m using a Pi 3 so it’s fairly old. I’m not aware of how one would add these flags for electron. I’m not sure where that line that starts chromium actually is.

The dockerfile was just the standard one from their github.