Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"Companion unloaded" when installing

Almost at every other `install` (via the Fitbit SDK CLI) attempt, the companion 'unloads' while loading the app. This means the watch app cannot talk to the companion and I have to issue the `install` command again and lose even more time (it doesn't help that all data needs to go over the internet and that there's no emulator for Linux).

 

output on the CLI:

 

Launching app
[17:53:06]       App: App Started
[17:53:07]       App: Watch app up                                                                                                                           (app/index.js:5,1)
[17:53:07]       App: Launch complete - durations: foregrounding(1006ms), first paint(5ms), total(1019ms).
[17:44:04]  Settings: Unloading companion…
[17:44:04] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                   (js-engine-bootstrap.html:9,1)
[17:44:04] Companion: Balance Calculator up                                                                                                (companion/BalanceCalculator.js:3,1)
[17:44:04] Companion: Companion up                                                                                                                     (companion/index.js:4,1)
[17:44:04] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/9686971d-4483-462a-80ba-dbb09db593d6/0x085bd965dba7b674/companion.js                                                                                                                                                 (js-engine-bootstrap.html:9,1)
[17:44:04]  Settings: Companion launched by [launchedOnTracker]
[17:53:08]       App: Contacting companion                                                                                                          (app/MessageService.js:6,9)
[17:44:06]  Settings: Companion unloaded
[17:53:09]       App: Getting data from Remote Service            

 

Why the hell would it unload the companion when I'm installing?

 

Sometimes I'll also get the following messages at launch: App closed on Device, unloading companion in 3 seconds... Unloading Companion... Companion unloade. But I'm not sure if this is related.

Best Answer
0 Votes
7 REPLIES 7

The installation process involves first uninstalling, then installing both the app and companion. That's why you'll see it unload. You shouldn't need to install twice though.

 

The companion lifecycle doesn't guarantee that the companion won't unload, but a message from the device to the companion should wake it again.

 

Some developers use the simulator on Linux with Wine. If you search on Discord I think you'll find the config they use.

 

The command line tools are evolving, and hopefully we'll get offline development at some point.

Best Answer

Hi Jon

 

 

I can only dream of offline development. Really looking forward!

 

Yes I understand that the installation process should uninstall and unload everything. But the unloading of the companion should happen _before_ launching the newly installed app, not after it has already launched and while it is trying to talk with said companion (that is now not reachable).

 

I'm going to hold off on trying to get Wine working (enough rabbit holes with development already :)) and wait for the native client or offline development to happen 🙂 Thanks

Best Answer
0 Votes

What you might be seeing is the companion for the default clock unload, in addition to your app's companion.

 

1. Your app uninstalls and its companion unloads

2. Default clock loads with its companion

3. Your new app version installs with its companion

4. Clock unloads and its companion

5. Your app is loaded

 

In roughly that order, but it may be slightly out of sync from that.

Best Answer
0 Votes

That's comforting, however I see my app often times not being able to connect to the companion at all; or even when the companion clearly says "hi" to the app, nothing else is happening.

 

It seems like the stability of the connection between device and companion isn't at all what it was on Pebble. I'd like to see improvement on that.

Best Answer

So below is the output of my regular install cycle. The first one fails, the second one succeeds. So I always have to run install twice to test, making development a lot slower. But this isn't entirely consistent: sometimes I will have two successive installs go through.

 

When the app says "We talkin'" it means it has just received a message { command: "hi" } from the companion (which I do as a way to establish that the connection is up, so I can notify the user).

 

So it's impossible for me to tell which companion is being unloaded (that of the default watch or the menu, or the companion for the app I'm developing) but it seems consistent that if I get "Settings: Companion unloaded" just after "App: Contacting companion", the app hangs and I have to reinstall to make things work.

 

fitbit$ install
No app package specified. Reloading ./build/app.fba.
Loaded appID:9686971d-4483-462a-80ba-dbb09db593d6 buildID:0x0fcd3ab35aaba3d0
Sideloading app: 100% completed
Sideloading companion: 100% completed
Launching app
[10:43:39]       App: App Started
[10:43:39]  Settings: Unloading companion…
[10:43:39] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                   (js-engine-bootstrap.html:9,1)
[10:43:39] Companion: Balance Calculator up                                                                                                (companion/BalanceCalculator.js:4,1)
[10:43:39] Companion: Companion up                                                                                                                     (companion/index.js:4,1)
[10:43:39]       App: Watch app up                                                                                                                           (app/index.js:5,1)
[10:43:39]       App: Launch complete - durations: foregrounding(1058ms), first paint(6ms), total(1078ms).
[10:43:39] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/9686971d-4483-462a-80ba-dbb09db593d6/0x0fcd3ab35aaba3d0/companion.js                                                                                                                                                 (js-engine-bootstrap.html:9,1)
[10:43:39]  Settings: Companion launched by [launchedOnTracker]
[10:43:40]       App: Contacting companion                                                                                                          (app/MessageService.js:6,9)
[10:43:41]  Settings: Companion unloaded
[10:43:41]       App: We talkin'                                                                                                                    (app/MessageService.js:6,9)
fitbit$ install
No app package specified. Reloading ./build/app.fba.
Loaded appID:9686971d-4483-462a-80ba-dbb09db593d6 buildID:0x0fcd3ab35aaba3d0
Sideloading app: 100% completed
Sideloading companion: 100% completed
Launching app
[10:44:05]       App: App Closed
[10:44:05]       App: App Closed
[10:44:06]       App: App Started
[10:44:06]       App: Watch app up                                                                                                                           (app/index.js:5,1)
[10:44:06]       App: Launch complete - durations: foregrounding(659ms), first paint(5ms), total(671ms).
[10:44:07] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                   (js-engine-bootstrap.html:9,1)
[10:44:07] Companion: Balance Calculator up                                                                                                (companion/BalanceCalculator.js:4,1)
[10:44:07] Companion: Companion up                                                                                                                     (companion/index.js:4,1)
[10:44:07] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/9686971d-4483-462a-80ba-dbb09db593d6/0x0fcd3ab35aaba3d0/companion.js                                                                                                                                                 (js-engine-bootstrap.html:9,1)
[10:44:07]  Settings: Companion launched by [launchedOnTracker]
[10:44:08]       App: Contacting companion                                                                                                          (app/MessageService.js:6,9)
[10:44:11]       App: We talkin'  
[10:44:13] Companion: Giving my device what it wants                                                                                                  (companion/index.js:24,1)
[10:44:13]       App: Message Received       (app/MessageService.js:6,9)

 

Best Answer
0 Votes

Hi, I'm seeing absolutely the same with the newest tools.

I need to install twice everytime to get the app talking to companion, since the first time, after install and launch of the app, companion gets unloaded. 

 

The companion is unloaded roughly 5 seconds after the previously installed app closes, even though I install a new app and establish messaging inbetween.

Best Answer

When the companion is unloaded there is no open connection to the device.  Sending a message from the device would not reach the companion as it would be in an invalid state.  Any sample code as to how to actually message a sleeping companion?

Best Answer