Windows version of compiled app path must have string


#1

Electron 1.7.8

Linux compiled app doesn’t show any errors when I launch my application but the Windows version does, I found the culprit but don’t know how to fix the error which has to do with the code that uses flash
path.join seems to be the one causing the issue in my code but only on the Windows version of my application.

here is my code

const {app, BrowserWindow} = require('electron');
const path = require('path')

var win

// Quit when all windows are closed.
app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit()
})

// Specify flash path, supposing it is placed in the same directory with main.js.
let pluginName
switch (process.platform) {
case 'win':
pluginName = 'pepflashplayer.dll'
break
case 'darwin':
pluginName = 'PepperFlashPlayer.plugin'
break
case 'linux':
pluginName = 'libpepflashplayer.so'
break
}
//Disables VSync
app.commandLine.appendSwitch('disable-gpu-vsync')
//Dual GPU Support
app.commandLine.appendSwitch('supports-dual-gpu=true')

app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName))
// Optional: Specify flash version, for example, v17.0.0.169
app.commandLine.appendSwitch('ppapi-flash-version', '21.0.0.151')

app.on('ready', () => {
let win = new BrowserWindow({
width: 1350,
height: 900,
icon: __dirname + '/icon.png',
webPreferences: {
plugins: true,
nodeIntegration: false
}
})
win.loadURL('file://' + __dirname + '/index.html') // Load splash screen
setTimeout(function () {
win.loadURL('http://examplewebsite.com')
}, 3000) // Load store page after 3 secs
win.webContents.on('will-navigate', ev => {
ev.preventDefault()
})
// Emitted when the window is closed.
win.on('closed', function() {
// Remove mainWindow.on('closed', function() { if you want the menu back
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
})
})

#2

Please use fenced code blocks to make your code more readable. This will use monospace fonts, highlight the code and preserve indentation.


#3

Is that to make it neater or to fix the issue?


#4

Why ask a question after it’s been answered :stuck_out_tongue:


#5

I’m a little confused about your answer on what you want me to do exactly which is why I answering your question with another question. :stuck_out_tongue:

Where exactly do I do fenced block sorry?


#6

I suggested to edit your initial post and wrap that code in GfM code fences. It has several benefits:

Benefits:

  • code-highlighting
  • indentation
  • monospaced font
  • proper quotes (otherwise copy&paste produces invalid code)

See the difference for yourself:

1. not in code fences

const example (name) => {
return console.log(`Cool story, ${name}`);
}

2. in code fences

const example (name) => {
    return console.log(`Cool story, ${name}`); 
}

See the benefit?

I posted a link for that!


#7

Thank you for the help and examples ans understand what your getting at but may I get some assistance in any errors in my code or what may be causing this weird issue? I am also still learning JavaScript and don’t know where to start exactrly.


#8

If people are able to read your code, chances are much higher that somebody can help you. Currently, it’s unreadable and I personally wouldn’t bother reading a single line of this mess. If you expect anybody to copy & paste your code into an editor in order to help you, I’d find that pretty demanding, if not insulting. Besides, the code wouldn’t work anyway, since all the quotes are broken due to the bad formatting.

Anyway, I’ve done enough here. You could’ve saved us from having this rather tiresome discussion by investing 3 seconds of your precious time to properly format ycode of yours. Good luck!


#9

That’s a bit rude/disrespectful and unhelpful to assume that, yes my code works just fine… The issue popped up randomly after a electron update breaking the code only on the compiled Windows version but not the Linux version also any non elitist behaviour or helpful person would still help out and as for formatting I learnt from the official Electron pages and other places…

Obviously you are not suited to be on this forum or to help anyone and should stop replying on this forum all together because this is just disgraceful behaviour and mine set to have on how to help anyone even someone that is just learning…


#10

Hello.

Please remove for a moment the frustration from the equation.
Realize @idleberg
…the best qualified to help you.
…he was aiming to help.
…as an expert, he is not obliged to be respectful.

Ignore for the moment his personality traits.
Now read the suggestions he is making.
Many times when organising the format of your code, issue comes to light.
I realise that does not mean it is the case for this situation.

As it is now, I (a novice) could not even format your code properly in a short time.

Please use the following format to publish your code in this topic:

```javascript
const myCode = 'place it here';
```

Which will look like:

const myCode = 'place it here';

I hope you find your answer.
Regards.


#11

Pot meets kettle?

We’re all here because we have free time and find it interesting to help people who have problems. You can’t expect people to help you if your code isn’t formatted properly, because we don’t want to perform a lot of extra work when you could have done the very simple step of formatting your post or linking to a GitHub repo.

When you are asking people to volunteer their work for you, don’t put any obstacles in their way or they will simply decide to not help you.


#12

@danPadric seems to explain it better as well as a lot nicer/helpful explaining what I had to do so now I have formatted my code, I understand that we are all here in our free time to help out but you didn’t seem friendly or willing to want to help. Now for others this would put them off completely from wanting to ask for help. Expert or not you still need to respect the person who is new or still learning nor did I get angry or frustrated replying calmly and maturely.

So lets get to the meat of the issue here, the issue here seams to be that one bit of code that loads up the flash plugin which only til now effects the Windows build but nothing else.


#13

Thank you for your compliment.

Sadly I now regret stepping in.
Your code is not human read friendly - is it?
Making it human friendly is formatting.
What I have shown you is the doorway to ensure the formatting is respected.

The situation now is like you have arrived at the Queen’s Invitation Ball.
Now you have a tie on as it is a “collar-and-tie” affair.
But your shoes have mud on them.
You did not bother to change clothes,
after the fox hunt of the afternoon.

I know “formatting” is not what you asked about.
However for me - if my eyes see such chaos,
my brain does not concentrate on the details.

Sorry I am not able to work on your team.


#14
const {
  app,
  BrowserWindow
} = require('electron');
const path = require('path')

var win

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  if (process.platform != 'darwin')
    app.quit()
})

// Specify flash path, supposing it is placed in the same directory with main.js.
let pluginName
switch (process.platform) {
  case 'win':
    pluginName = 'pepflashplayer.dll'
    break
  case 'darwin':
    pluginName = 'PepperFlashPlayer.plugin'
    break
  case 'linux':
    pluginName = 'libpepflashplayer.so'
    break
}
//Disables VSync
app.commandLine.appendSwitch('disable-gpu-vsync')
//Dual GPU Support
app.commandLine.appendSwitch('supports-dual-gpu=true')

app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName))
// Optional: Specify flash version, for example, v17.0.0.169
app.commandLine.appendSwitch('ppapi-flash-version', '21.0.0.151')

app.on('ready', () => {
  let win = new BrowserWindow({
    width: 1350,
    height: 900,
    icon: __dirname + '/icon.png',
    webPreferences: {
      plugins: true,
      nodeIntegration: false
    }
  })
  win.loadURL('file://' + __dirname + '/index.html') // Load splash screen
  setTimeout(function() {
    win.loadURL('http://examplewebsite.com')
  }, 3000) // Load store page after 3 secs
  win.webContents.on('will-navigate', ev => {
    ev.preventDefault()
  })
  // Emitted when the window is closed.
  win.on('closed', function() {
    // Remove mainWindow.on('closed', function() { if you want the menu back
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  })
})

#15

Thank you for helping me format it, I have made the changes

and to everyone else, after formatting it no it wasn’t a issue with my code just like I said…

the bug still persists


#16

Found the issue

win.on(‘closed’, function() {