Fix for Tauri v2 app crashing on startup in WSL2 with gdk-pixbuf panic: "data.len() must fit the width, height, and row_stride". Use when: (1) Tauri app panics immediately on launch in WSL2/Linux, (2) error occurs in gdk-pixbuf crate at pixbuf.rs, (3) crash happens before window renders, (4) app works on Windows/macOS but fails on Linux/WSL2. The fix is to use an empty icon array in tauri.conf.json to bypass icon loading issues with GTK.
Tauri v2 desktop application crashes immediately on startup when running in WSL2 (Windows Subsystem for Linux) with WSLg. The panic occurs in the gdk-pixbuf crate before the window can render.
Error message:
thread 'main' panicked at /home/user/.cargo/registry/src/.../gdk-pixbuf-0.18.5/src/pixbuf.rs:44:13:
data.len() must fit the width, height, and row_stride
When this occurs:
Running steptauri.conf.json under bundle.iconNOT this issue if:
Set an empty icon array in tauri.conf.json:
{
"bundle": {
"active": true,
"targets": "all",
"icon": []
}
}
The gdk-pixbuf library in GTK has issues loading certain icon formats or dimensions in the WSL2/WSLg environment. By providing an empty icon array, Tauri skips the problematic icon loading during window initialization. The app will use a default system icon instead.
If you need custom icons, ensure they are:
convert -size 32x32 xc:'#3b82f6' -type TrueColorAlpha -define png:color-type=6 icon.pngEven with proper icons, the empty array workaround may still be needed on WSL2.
After applying the fix:
npm run tauri:dev or cargo tauri devRunning /path/to/appps aux | grep your-app-name to confirm process is runningBefore (crashes):
{
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/icon.png"
]
}
}
After (works):
{
"bundle": {
"active": true,
"targets": "all",
"icon": []
}
}
echo $DISPLAY and /mnt/wslg/ exists