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

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

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)
			}
		]);
	})
};

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.

@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.

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

I’ll hopefully have a fix up soon.