ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 303 forks source link

Ionic production build consumes all memory without successfully build .apk Memory LEAK #1429

Open Stradivario opened 6 years ago

Stradivario commented 6 years ago

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/ http://ionicworldwide.herokuapp.com/

Short description of the problem:

ionic cordova build android --aot --prod is consuming all memory available and it is not building application!

What behavior are you expecting?

Application should be build without much effort

Steps to reproduce: 1.nvm install 8.9.0/8.9.4/10.0.0 2.npm i -g ionic cordova 3.ionic cordova build android --aot --prod

screenshot from 2018-05-05 00-57-04

insert any relevant code between the above and below backticks
cli packages: (/home/rampage/.nvm/versions/node/v10.0.0/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.1.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v10.0.0
    npm  : 6.0.0
    OS   : Linux 4.15

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro
Stradivario commented 6 years ago

Tested also with Node 8.9.0 and 8.9.4 it is the same as 10.0.0

Leonavas commented 6 years ago

+1 tested with node v6.11.5 and v9.11.1

jessicastorm1986 commented 6 years ago
cli packages: (C:\Users\jessica\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0 browser 5.0.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.10.3
    npm               : 6.0.1
    OS                : Windows 8.1
audacitus commented 6 years ago

Your best bet for now may be using the following in stead of --prod :

‘--minifycss --minifyjs --aot’

I'm mobile now, but the issue seems to be narrowed down to --optimizejs, which --prod uses, but causes the build to consume memory but never complete. I read somewhere on another ticket that I may be a webpack thing, but as there aren't any more updates to 3.9, we're stuck with this.

On Tue, 29 May 2018, 08:19 jessicastorm1986, notifications@github.com wrote:

  • 1 , what is the solution i need to upload latest changes to android play store ? below are my info versions

cli packages: (C:\Users\jessica\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : android 7.0.0 browser 5.0.3
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 25.2.5
Node              : v6.10.3
npm               : 6.0.1
OS                : Windows 8.1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-app-scripts/issues/1429#issuecomment-392677129, or mute the thread https://github.com/notifications/unsubscribe-auth/APPh0qaFzCQVCPfWszGRb0_XcxvOgcLeks5t3PZygaJpZM4TzUsw .

jessicastorm1986 commented 6 years ago

Well ionic cordova build android --aot worked, so according to you this is our solution for the moment ? and once we shift to ionic 4.0 we will have to find new ways..

audacitus commented 6 years ago

For the moment, yes. From what I've read and experienced it seems to happen with large projects (mine is 30+ screens with lazy loading). As --prod uses the --minifycss, --minifyjs and --optimizejs, using two out of three gets the build done with a lag free response. Perhaps they will look into it after 4.0, but this will have to do.

On Tue, 29 May 2018, 09:02 jessicastorm1986, notifications@github.com wrote:

Well ionic cordova build android --aot worked, so according to you this is our solution for the moment ? and once we shift to ionic 4.0 we will have to find new ways..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic-app-scripts/issues/1429#issuecomment-392688198, or mute the thread https://github.com/notifications/unsubscribe-auth/APPh0pPyUqZw4TpErQRPgGow_sLCEvp4ks5t3QCrgaJpZM4TzUsw .

jessicastorm1986 commented 6 years ago

alright, i have more than 60 + SCREENS and these kind of unexpected issues waste our time so much, wish ionic people understand this and provide us a simple smooth solution.

We use unity3d for game development, never got into any stupid errors while making a build ever..whenever i try to make a --prod or --aot build i get nervous, got phobia for this :(

Stradivario commented 6 years ago

@jessicastorm1986 remove the ^ inside package.json and install your dependencies.After that you will have package-lock.json everytime when you try to install use npm install --from-lock-file this way you will install everytime the same dependencies.Downside is that you will not get new updates but you will decide when to update, it costs time but i think it is the right way doing things.

About issue i face it long time ago and i decided to lock my working version and to be sure that my app will go into production without problems.Let me share my package.json with OLD (but gold) working version :)

{
  "name": "",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "build:prod:aot": "ionic build --prod --aot",
    "start:docker": "docker-compose up -d --force-recreate",
    "build:docker": "docker build -t juice/mobile/aot:latest ."
  },
  "dependencies": {
    "@angular/animations": "5.2.9",
    "@angular/common": "5.2.9",
    "@angular/compiler": "5.2.9",
    "@angular/compiler-cli": "5.2.9",
    "@angular/core": "5.2.9",
    "@angular/forms": "5.2.9",
    "@angular/http": "5.2.9",
    "@angular/platform-browser": "5.2.9",
    "@angular/platform-browser-dynamic": "5.2.9",
    "@ionic-native/background-geolocation": "^4.7.0",
    "@ionic-native/core": "^4.7.0",
    "@ionic-native/facebook": "^4.7.0",
    "@ionic-native/geolocation": "^4.7.0",
    "@ionic-native/google-maps": "^4.7.0",
    "@ionic-native/location-accuracy": "^4.7.0",
    "@ionic-native/onesignal": "^4.7.0",
    "@ionic-native/secure-storage": "^4.7.0",
    "@ionic-native/splash-screen": "4.6.0",
    "@ionic-native/status-bar": "4.6.0",
    "@ionic/pro": "1.0.20",
    "@ionic/storage": "2.1.3",
    "@types/node": "^9.6.6",
    "angularfire2": "^5.0.0-rc.6.0",
    "cordova-android": "7.1.0",
    "cordova-browser": "5.0.3",
    "cordova-ios": "4.5.4",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-facebook4": "git+https://github.com/amritk/cordova-plugin-facebook4.git",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-googlemaps": "^2.2.9",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^1.2.0",
    "cordova-plugin-mauron85-background-geolocation": "^2.3.5",
    "cordova-plugin-request-location-accuracy": "^2.2.2",
    "cordova-plugin-secure-storage": "^2.6.8",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "firebase": "^4.12.1",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "ngx-cache-layer": "^1.6.2",
    "onesignal-cordova-plugin": "^2.3.3",
    "rxjs": "5.5.8",
    "subscriptions-transport-ws": "^0.9.8",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.8",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-secure-storage": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "onesignal-cordova-plugin": {},
      "cordova-plugin-request-location-accuracy": {},
      "cordova-plugin-mauron85-background-geolocation": {
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "23+",
        "ICON": "@mipmap/icon",
        "SMALL_ICON": "@mipmap/icon",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": "$PACKAGE_NAME.account",
        "CONTENT_AUTHORITY": "$PACKAGE_NAME",
        "ALWAYS_USAGE_DESCRIPTION": "This app always requires location tracking"
      },
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-facebook4": {
        "APP_ID": "",
        "APP_NAME": "",
        "ANDROID_SDK_VERSION": "4.+"
      },
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "",
        "API_KEY_FOR_IOS": "",
        "PLAY_SERVICES_VERSION": "12.0.0",
        "ANDROID_SUPPORT_V4_VERSION": "24.1.0"
      },
      "cordova-plugin-statusbar": {}
    },
    "platforms": [
      "android",
      "ios",
      "browser"
    ]
  }
}

Regards, Kristiyan Tachev

jayordway commented 6 years ago

I updated the @angular-devkit/build-optimizer which @ionic/app-scripts leverages with version 0.0.35, for app-scripts version 3.1.8 and I updated @angular-devkit/build-optimizer to version 0.6.8. Now I can do a production build with ionic 3.9.2 and firebase 5.3.0

Note that something around or after @firebase/database 0.2.1 is the first version that causes the build to not finish.

SpellChucker commented 6 years ago

This is an issue for us too and is absolutely related to the --optimizejs flag. Without it, our builds take max 5 minutes. With it, our builds take 30+ minutes. It sucks, but we're going to have to move forward without the --optimizejs flag. We don't even use firebase (which seems to be a lot of people's problems). What does the --optimizejs flag even do??

2mia commented 6 years ago

@jayordway, worked for me npm i @angular-devkit/build-optimizer@0.7.2 made the build finish with ionic under 1.2GB

Bengejd commented 6 years ago

@SpellChucker check out my solution on another thread, to being able to run ionic cordova build --device --prod --aot --minifyjs --minifycss --optimizejs --release. I hope it helps!

leiamac commented 5 years ago

@jayordway In my case just doing ´´´npm i @angular-devkit/build-optimizer --save-dev´´ solved the issue. I also have firebase installed.