I’m just learning about meteor and cordova integration, but I’m running into something I can’t explain. Sorry this is long but I wanted to make sure the explanation is understandable.
When I ran my app on on Android or iOS, I noticed that the first time I open it after it is installed, the UI renders fine but then re-renders making the UI appear to flash. If I close the app and re-open it, it does not re-render (no flash.)
I thought it was something I was doing in my code but I couldn’t figure out what, so I tried it with the sample app you get when you first run meteor create
.
Interestingly it seems to happen here too. I added the Android SDK and platform, then ran the app on my device using meteor run android-device
. I added a console.log()
to the counter()
function to show it loads more than once.
Here is the output after that app is first installed and run:
$ meteor run android-device
[[[[[ ~/web/projects/simple ]]]]]
=> Started proxy.
=> Started MongoDB.WARNING: You are testing your app on a remote device. For the mobile app to be able to
connect to the local server, make sure your device is on the same network, and
that the network configuration allows clients to talk to each other (no client
isolation).
=> Started your app.=> App running at: http://localhost:3000/
=> Started app on Android Device.
I20160224-09:10:25.815(-5) (android:http://meteor.local/app/simple.js:15) getting the counter.
I20160224-09:10:27.952(-5) (android:http://meteor.local/app/simple.js:15) getting the counter.
You can see that it prints out the log statement twice about 2 seconds apart.
Here is the output after the app is already installed (I’ve already run meteor run android-device
once, now I’m running it again):
$meteor run android-device
[[[[[ ~/web/projects/simple ]]]]]
=> Started proxy.
=> Started MongoDB.WARNING: You are testing your app on a remote device. For the mobile app to be able to
connect to the local server, make sure your device is on the same network, and
that the network configuration allows clients to talk to each other (no client
isolation).
=> Started your app.=> App running at: http://localhost:3000/
=> Started app on Android Device.
I20160224-09:11:59.262(-5) (android:http://meteor.local/app/simple.js:15) getting the counter.
No second log statement because the UI only renders one time.
Interestingly, when doing this with my app, it behaves the same, but because I am running it with meteor run android-device --mobile-server
the first time it renders the UI it appears to be from
android:http://meteor.local/app/client/client.js
but the second time it renders it is from
android:http://meteor.local/c06431d46ea3c8ccc8bc6e76bdfe5bb68ed30c1.js
.
I presume this is coming from the server I defined with --mobile-server
. Again, this only happens the first time I run the app after installing it. After that when I run the app it appears to load the UI from the server and only renders once.
So - is this expected behavior?
How can I prevent it flashing on first run of the app after install?
Thanks for your help!