This has been seen on devices - Forerunner 735xt and Vivoactive 4 have been confirmed, not sure what others are affected.
However, it is VERY easy to replicate on the simulator, and it appears that (on the simulator at least) it is easier on some devices than others.
EXPECTED RESULTS:
App should display on start-up every time without fail.
ACTUAL RESULTS:
The app sporadically fails to display despite
STEPS TO REPRODUCE IN VSCODE WITH SIMULATOR:
1. Build a project as per the below classes.
2. Build for 735xt.
3. Press F5 to run the app in simulator.
4. Check whether the screen has shown.
5. Repeat (sometimes happens every two or three, sometimes every 20) until screen doesn't display at all in the simulator.
6. Verify in the console for VSCode that all of initiialize, onLayout and onUpdate have been called in the correct order.
7. Use "down arrow" to call WatchUi.requestUpdate() and verify that the app is indeed running correctly
CLASSES
using Toybox.Application;
using Toybox.WatchUi;
using Toybox.System;
class lab2App extends Application.AppBase {
var view;
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state) { }
// onStop() is called when your application is exiting
function onStop(state) { }
// Return the initial view of your application here
function getInitialView() {
view = new lab2View();
return [ view, new lab2Delegate() ];
}
function onSettingsChanged() {
System.println("onSettingsChanged");
view.onSettingsChanged();
WatchUi.requestUpdate();
}
}
using Toybox.WatchUi;
class lab2Delegate extends WatchUi.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
}
function onKey(keyEvent) {
if(keyEvent.getKey() == WatchUi.KEY_DOWN) {
System.println("KEY DOWN");
WatchUi.requestUpdate();
}
return false;
}
}
using Toybox.WatchUi;
using Toybox.Graphics as G;
class lab2View extends WatchUi.View {
function initialize() {
View.initialize();
System.println("initialize");
}
// Load your resources here
function onLayout(dc) {
// setLayout(Rez.Layouts.MainLayout(dc));
System.println("onLayout");
}
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() { }
// Update the view
function onUpdate(dc) {
// Call the parent onUpdate function to redraw the layout
// View.onUpdate(dc);
System.println("onUpdate");
dc.setColor(G.COLOR_WHITE,G.COLOR_WHITE);
dc.clear();
dc.setColor(G.COLOR_BLACK,G.COLOR_TRANSPARENT);
dc.drawText(dc.getWidth()/2, dc.getHeight()/2, G.FONT_LARGE, "text", G.TEXT_JUSTIFY_CENTER|G.TEXT_JUSTIFY_VCENTER);
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() { }
}