ionic-team / capacitor-assets

Local Capacitor icon/splash screen resource generation tool
MIT License
493 stars 96 forks source link

Generate resources fail in M1: Segmentation fault #443

Open estebancastrosola opened 1 year ago

estebancastrosola commented 1 year ago

Hello! I have a problem with capacitor/assets (and also with cordova-res) that I can't generate the resources for iOS on an apple M1 chip. Always the error: segmentation fault

flowww@MacBook-Air-de-FLOWww FLOWww.Apps_FLOWwwMe % npm list -g /opt/homebrew/lib ├── @angular/cli@11.0.5 ├── @capacitor/assets@2.0.4 ├── @ionic/cli@6.20.4 ├── cordova-res@0.15.4 ├── ios-deploy@1.11.4 └── npm@9.1.2

npx capacitor-assets generate --ios
Generating assets for ios zsh: segmentation fault npx capacitor-assets generate --ios

cordova-res ios WARN: No config.xml file in directory. Skipping config. zsh: segmentation fault cordova-res ios

I have installed vips with brew (in arm64 arch) even sharp, but it still doesn't work...

flowww@MacBook-Air-de-FLOWww FLOWww.Apps_FLOWwwMe % brew info vips ==> vips: stable 8.13.3 Image processing library https://github.com/libvips/libvips /opt/homebrew/Cellar/vips/8.13.3 (96 files, 5.6MB) * Poured from bottle on 2022-11-22 at 19:39:53 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/vips.rb License: LGPL-2.1-or-later ==> Dependencies Build: gobject-introspection ✔, meson ✘, ninja ✔, pkg-config ✔ Required: cairo ✔, cfitsio ✔, cgif ✔, fftw ✔, fontconfig ✔, gettext ✔, glib ✔, imagemagick ✔, jpeg-xl ✔, libexif ✔, libgsf ✔, libheif ✔, libimagequant ✔, libmatio ✔, librsvg ✔, libspng ✔, libtiff ✔, little-cms2 ✔, mozjpeg ✔, openexr ✔, openjpeg ✔, openslide ✔, orc ✔, pango ✔, poppler ✔, webp ✔ ==> Analytics install: 13,339 (30 days), 40,128 (90 days), 120,216 (365 days) install-on-request: 13,000 (30 days), 39,042 (90 days), 116,922 (365 days) build-error: 0 (30 days)

Any ideas?

mlynch commented 1 year ago

I'm not able to reproduce but will leave this open in case others have a similar issue and have more to add, thanks

knaito-asial commented 1 month ago

I encountered this issue with capacitor-assets 3.0.5. On my Apple Silicon Mac, build script was running in a Docker container which is x64 architecture Linux.

After updating sharp to 0.33.4 and use Node.js v18.17.0, the segmentation fault disappeared. For more details about node version, see https://github.com/withastro/astro/issues/9345#issuecomment-1870663966 .

viking2917 commented 2 weeks ago

[UPDATE]: I botched the copy of the new sharp into the directory ./node_modules/@capacitor/assets/node_modules/sharp. When I copied the files properly, the seg fault disappeared. Thanks @knaito-asial


I have the same issue, except it only crashes on Android, not iOS, e.g.

npx capacitor-assets generate --android
fails, but npx capacitor-assets generate --ios works

@knaito-asial how did you upgrade sharp?

I did npm install sharp but that produced a new installation of sharp, rather than updating the one under node_modules/@capacitor/assets@3.0.5. I then copied the new sharp directory into the capacitor/assets/node_modules/sharp directory, but neither of those fixed the segmentation fault...

My ionic info in case relevant:

Ionic:

Ionic CLI : 7.2.0 (/Users/markwatkins/.nvm/versions/node/v20.14.0/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 7.8.6 @angular-devkit/build-angular : 16.2.14 @angular-devkit/schematics : 16.2.14 @angular/cli : 16.2.14 @ionic/angular-toolkit : 9.0.0

Capacitor:

Capacitor CLI : 6.0.0 @capacitor/android : 6.0.0 @capacitor/core : 6.0.0 @capacitor/ios : 6.0.0

Utility:

cordova-res : not installed globally native-run : 2.0.1

System:

NodeJS : v20.14.0 (/Users/markwatkins/.nvm/versions/node/v20.14.0/bin/node) npm : 10.7.0 OS : macOS Unknown