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

failed to create tray icon: error processing argument at index 0, conversion failure #21154

Closed
3 tasks done
vladimiry opened this issue Nov 16, 2019 · 17 comments
Closed
3 tasks done

Comments

@vladimiry
Copy link

vladimiry commented Nov 16, 2019

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 8.0.0-beta2
  • Operating System: Linux, Windows (have not tested on macOS)
  • Last Known Working Electron version: 7.1.1

Expected Behavior

Tray icon with the specified image created.

Actual Behavior

Unhandled error processing argument at index 0, conversion failure error error is occurring. No tray icon created.

To Reproduce

https://github.com/vladimiry-playground/electron-quick-start-tray-issue

Screenshots

8 0 0-beta 2

8 0 0-beta 2-win

Tray icon with the specified image created if used v7.1.1 and below:

7 1 1

Additional Information

If used 8.0.0-beta2 there is no error if I construct the tray using the native image module like new Tray(nativeImage.createFromPath("image path")) but there is no visible tray icon either, but works for v7.1.1 and below.

@vladimiry vladimiry changed the title failed to create tray icon: error processing argument at index 0, conversion failure error failed to create tray icon: error processing argument at index 0, conversion failure Nov 16, 2019
@sofianguy sofianguy added this to Unsorted Issues in 8.2.x Nov 19, 2019
vladimiry added a commit to vladimiry/ElectronMail that referenced this issue Nov 20, 2019
* TODO (switch back to upstream "node-spellchecker") atom/node-spellchecker#127
* TODO (blocker) electron/electron#20700
* TODO (blocker @electron v8) electron/electron#21154
@sofianguy sofianguy moved this from Unsorted Issues to Blocks Stable in 8.2.x Nov 20, 2019
@momakes3
Copy link

momakes3 commented Nov 21, 2019

Can confirm also happens on mac.
I just upgraded from 7.1.1 to 8.0.0-beta.3 and I got the error.

Error processing argument at index 0, conversion failure from /Users/mo/dev/there3/desktop/main/static/tray/iconTemplate.png

I'm on macOS, and this was working on 6 and 7 version lines.

@vladimiry
Copy link
Author

Ok, so as I expected macOS is also affected.

@codebytere
Copy link
Member

It's an issue with underlying type marshalling between c++ and js - it's platform agnostic.

I'll hopefully have a fix up soon.

@vladimiry
Copy link
Author

@codebytere I can confirm the issue got resolved with 8-beta4 release when running on Windows. On Linux, there is no error anymore but no tray icon created either. So the expected behavior has not been met.

Expected Behavior
Tray icon with the specified image created.

@vladimiry
Copy link
Author

@codebytere should I place a new issue or this one is fine for tracking the absence of tray icon when running @electron@^8 on Linux?

@sofianguy sofianguy moved this from Blocks Stable to Fixed in 8.0.0-beta.4 in 8.2.x Dec 9, 2019
@sofianguy
Copy link
Contributor

fixed #21241

@vladimiry
Copy link
Author

@sofianguy, I wrote above that I tested 8-beta4 release with #21241 fix included and the issue has not been completely handled:

Expected Behavior
Tray icon with the specified image created.

So I'm placing a new issue, #21445.

@momakes can you confirm the issue is completely fixed for you when running macOS?

@vladimiry
Copy link
Author

@momakes, the fix has been already verified on macOS by @codebytere as noted here #21445 (comment) so I'm withdrawing my question to you.

@FI-GGG
Copy link

FI-GGG commented Feb 28, 2020

"devDependencies": {
	"electron": "^7.1.8",
	"electron-packager": "^14.2.1"
}

win10 1909 我使用electron-packager打包后运行exe就会产生这个错误,但如果直接运行elecrtron main.js就正常了,这是为什么?

@FI-GGG
Copy link

FI-GGG commented Feb 28, 2020

win10 1909 I run the exe after packaging with electron-packager will produce this error, but if you run elecrtron main.js directly, it is normal, why is this?

@betamos
Copy link

betamos commented Mar 13, 2020

I'm getting this error message when using a path to an icon on OS X Catalina with Electron 8.0.2 and 8.1.1, both with pdf and icns.

Using a png works, but there are other issues instead: if I use a 16x16px icon, its resolution is poor (due to retina display). Supplying another 32x32 icon suffixed with @2.png makes it too large - i.e. not adapting to retina.

@dsteinman
Copy link

dsteinman commented Apr 20, 2020

Please re-open this issue.

This is still occurring in Electron v8.2.3 on MacOSX, this is the latest version installed by Electron Forge.

@nornagon
Copy link
Member

@dsteinman I can't reproduce this with v8.2.3 on macOS 10.14. I tried @vladimiry's repository linked in the issue, https://github.com/vladimiry-playground/electron-quick-start-tray-issue, and it seems to work fine with no error messages.

@vladimiry
Copy link
Author

vladimiry commented Apr 21, 2020

The thing is that, in my experience, the error processing argument at index 0, conversion failure error message is not very informative, it's used for different cases. For example you get such message if you pass the *.ico file naming it as *.png.

@nornagon
Copy link
Member

Agreed, it's not a great error message.

@dsteinman
Copy link

dsteinman commented Apr 21, 2020

@dsteinman I can't reproduce this with v8.2.3 on macOS 10.14. I tried @vladimiry's repository linked in the issue, https://github.com/vladimiry-playground/electron-quick-start-tray-issue, and it seems to work fine with no error messages.

I just tried this as well, and it DOES work so it's probably a configuration error on my end.

I suppose the problem could be simply the file is not found. I'm using electron forge / webpack which mucks with the paths of the files.

@dsteinman
Copy link

dsteinman commented Apr 21, 2020

Okay, I figured it out. This will be useful for any Electron Forge users.

My tray path is coded as:

tray = new Tray(path.join(__dirname, 'assets', 'logoTemplate.png'));

The actual image is located in src/assets/logoTemplate.png

I had to modify webpage.main.config.js using the 'copy-webpack-plugin' npm module to copy src/assets into the webpack build directory.

contents of webpage.main.config.js;

const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const assets = [ 'assets' ]; // src/asset directory

module.exports = {
	entry: './public/electron.js',     // fyi this path is not the default supplied by electron forge
	module: {
		rules: require('./webpack.rules'),
	},
	devServer: {
		contentBase: './dist',
		hot: true,
	},
	plugins: assets.map(asset => {
		return new CopyWebpackPlugin([
			{
				from: path.resolve(__dirname, 'src', asset),
				to: path.resolve(__dirname, '.webpack/main', asset)
			}
		]);
	})
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
8.2.x
Fixed in 8.0.0-beta.4
Development

No branches or pull requests

8 participants