Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

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

Closed
jgw96 opened this issue Jan 24, 2017 · 16 comments
Closed

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

jgw96 opened this issue Jan 24, 2017 · 16 comments

Comments

@jgw96
Copy link
Contributor

jgw96 commented Jan 24, 2017

From @marcsyp on January 10, 2017 22:35

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.

Copied from original issue: ionic-team/ionic-framework#9944

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @danbucholtz on January 10, 2017 22:43

@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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @rapropos on January 11, 2017 0:25

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @tobiasmuecksch on January 11, 2017 7:47

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @tobiasmuecksch on January 11, 2017 7:53

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @pawelfrydrych on January 11, 2017 9:2

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.

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @mhartington on January 11, 2017 14:41

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @danbucholtz on January 11, 2017 15:31

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @marcsyp on January 11, 2017 23:59

@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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @rapropos on January 12, 2017 0:22

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.

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @danbucholtz on January 12, 2017 16:22

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @marcsyp on January 13, 2017 0:14

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @mhartington on January 13, 2017 1:58

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

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 24, 2017

From @marcsyp on January 13, 2017 5:48

When I get back from this business trip I'll try to recreate in a smaller
app, or bundle up the whole thing for you to look at. Thanks for responding.

Marc

On Jan 12, 2017 6:58 PM, "Mike Hartington" [email protected] wrote:

@marcsyp https://github.com/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.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
ionic-team/ionic-framework#9944 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACzflNmOsponm5f99jC4lLcENczd67q-ks5rRtpKgaJpZM4Lf-bk
.

@danbucholtz
Copy link
Contributor

@marcsyp,

Please provide more info and a basic repository to recreate the issue.

Thanks,
Dan

@marcsyp
Copy link

marcsyp commented Jan 24, 2017

Thanks Dan -- still working under a deadline to get something pushed out by Wednesday EOD, but I intend to put together something on this when I have a chance.

@danbucholtz
Copy link
Contributor

danbucholtz commented Feb 11, 2017

Since we use issues as an active backlog, we are starting to close inactive issues. Please provide a reproduction and open a new issue if you want us to revisit this issue.

Thanks,
Dan

@ionic-team ionic-team locked and limited conversation to collaborators Feb 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants