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

Dev build not working correctly - Platform.ready not firing #9944

Closed
marcsyp opened this issue Jan 10, 2017 · 15 comments
Closed

Dev build not working correctly - Platform.ready not firing #9944

marcsyp opened this issue Jan 10, 2017 · 15 comments
Labels
needs: reply the issue needs a response from the user

Comments

@marcsyp
Copy link

marcsyp commented Jan 10, 2017

Ionic version: (check one with "x")
[ ] 1.x
[X] 2.x

I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
Deviceready does not fire for at least 8 seconds in dev builds, causing the app to break (platform.ready() fails because ready does not exist on undefined). Using '--prod' works, but livereload is not available in prod builds as far as I know.

Expected behavior:
Using "ionic run android": Deviceready fires, does not time out, and app works. Livereload works.

Related code:

image

//error is related to the following piece of code:

 initializeApp() {
    this.platform.ready().then(() => {                                                             
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();

      this.hideSplashScreen();

      console.log('Platform ready.');
      console.log(this.stringToTime('445'));
      ...
   }
}

Platform is injected correctly and I can confirm that building with --prod does indeed work.

Other information:
As documented in this issue, upgrading to app-scripts 1.0.0 (and CLI 2.1.18) causes slow deviceReady in dev builds. Some people only have a slow load time, in my case, my app breaks because platform.ready() fails. The proposed solution is to build with the --prod flag, but this eliminates the possibility of running dev builds on the device.

Ionic info:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.47 (downgraded from 1.0.0, still have problems)
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v6.9.4
Xcode version: Not installed

package.json:

{
  "name": "augmenta",
  "author": "Marc Syp",
  "homepage": "http://zzz.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.47",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "Augmenta: An Ionic project"
}

tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

@mhartington as requested.

@danbucholtz
Copy link
Contributor

@marcsyp,

How slow are we talking here? What is the diff from when it was faster? Did you change anything related to your environment besides upgrading to 1.0.0 of app-scripts? My gut feeling is this is unrelated to app-scripts. Do you have any other info you can offer or a repository where I can easily recreate the issue?

Thanks,
Dan

@danbucholtz danbucholtz added the needs: reply the issue needs a response from the user label Jan 10, 2017
@rapropos
Copy link
Contributor

You may be able to at least work around the problem by increasing the loadUrlTimeoutValue preference in config.xml.

@tobiasmuecksch
Copy link

tobiasmuecksch commented Jan 11, 2017

@danbucholtz I can confirm, that the dev build of my app takes 5 (up to 10) seconds to load on my android device (which causes an asset load error) - compared to the prod version which takes less than a second on the very same device. No changes to the code of the app.

@tobiasmuecksch
Copy link

tobiasmuecksch commented Jan 11, 2017

@danbucholtz I could send you the source of our app via mail, since I am not allowed to make the repo public.

@pawelfrydrych
Copy link

I confirm that in app-scripts 1.0.0 app is loading much slower than in 0.0.45, but prod mode solve this problem.

@mhartington
Copy link
Contributor

@rapropos that is not really an ideal workaround, and should be avoided.

@danbucholtz
Copy link
Contributor

It sounds like this is working as expected, then. Development builds will be slower than prod builds because they don't use the ahead-of-time compiler.

I'm going to close this issue but will revisit if needed.

Thanks,
Dan

@marcsyp
Copy link
Author

marcsyp commented Jan 11, 2017

@danbucholtz Seriously?? not trying to be snarky here, but I'm having a hard time understanding how you can close this issue with "works as expected". Development builds breaking -- no way to run a development build on a device -- that's "works as expected" to you??

My deviceready fires after about 7-8 seconds, as you should see in the above screenshot. Meanwhile, the platform.ready() call fails, causing whitescreen.

Incidentally, @rapropos I did try your solution of defining the LoadUrlTimeoutValue explicitly to 20000, however I should note that by default it should already be set to 20000, and it did not make any difference. I suspect that perhaps app load and deviceReady/platformReady are perhaps not affected by this preference.

All that said -- I do not know precisely what the problem is -- not sure why the deviceReady firing slowly would cause a total app meltdown -- but I do know that it used to work and now it doesn't. Perhaps the slow build is not in fact the culprit. But I'd really like to get to the bottom of this so I can actually develop my app on the device, preferably with livereload so I don't have to wait 40 seconds for my build for every tiny change. If someone at Ionic could help us get there, that would be great.

Is there an option, for instance, to get the dev builds to use the AoT compiler? I don't mind waiting longer for the initial build if it means I can get livereload working.

Any help tracking this down appreciated.

Thanks,
Marc

@rapropos
Copy link
Contributor

Is there an option, for instance, to get the dev builds to use the AoT compiler?

$ ionic build android --aot

At the risk of incurring further @mhartington wrath,

I did try your solution of defining the LoadUrlTimeoutValue explicitly to 20000

When I ran into this problem, I bumped it to 800000, which at least allowed the app to launch and be debuggable, which was really what I needed at the time.

@danbucholtz
Copy link
Contributor

danbucholtz commented Jan 12, 2017

Try ionic run android --livereload.

If there is an issue here with ionic or app-scripts, we can look into it but it sounds like the app is just starting up slowly. That'll happen with Android when using development builds.

Thanks,
Dan

@marcsyp
Copy link
Author

marcsyp commented Jan 13, 2017

image

same issue with ionic run android --livereload

The app is not "just starting up slowly" -- the dev build is 100% broken. Perhaps the title of the issue is misleading. I thought it might be the slow loading which was causing the breakage, but it is possibly not the slow loading. If it just loaded slowly, I would be fine. But the dev builds are BROKEN. Ionic's Platform is undefined... therefore this.platform.ready() breaks the app.

My understanding was that Ionic Platform encapsulated the deviceReady callback -- but, it appears that the app tries to load platform.ready() before deviceready fires (it eventually does fire). Please look at the screenshot and let me know what else I need to do to show what is happening here. It seems others are having similar problems, but nobody has proposed a solution yet. I am confused as to why this is being called "works as normal". The way it was before was "works as normal" -- because it actually worked. This is a broken dev build.

Perhaps it is not due to slow loading, and therefore this issue should be closed. But if it is not slow loading, then please help me determine what the issue is so that we can fix it.

Thanks,
Marc

@mhartington
Copy link
Contributor

@marcsyp we have not been able to recreate this in our extensive testing. We've tested OSX/Windows ios and android and have not been able to create an situation where an app breaks on platform.ready.

How could we replicate this? What's your app look like? Does this happen with starter project? Or is this only happening with your app? We need more information to be able to figure out whats going on.

@marcsyp
Copy link
Author

marcsyp commented Jan 13, 2017 via email

@danbucholtz danbucholtz changed the title App-scripts 1.0.0 upgrade causes slow deviceready, dev build fails Dev build not working correctly - Platform.ready not firing Jan 13, 2017
@danbucholtz danbucholtz reopened this Jan 13, 2017
@jgw96
Copy link
Contributor

jgw96 commented Jan 24, 2017

This issue was moved to ionic-team/ionic-app-scripts#684

@jgw96 jgw96 closed this as completed Jan 24, 2017
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 4, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: reply the issue needs a response from the user
Projects
None yet
Development

No branches or pull requests

8 participants