Skip to content

Commit

Permalink
Cherry pick PR #4016: Load the system image if Installation Manager f…
Browse files Browse the repository at this point in the history
…ails (#4083)

Refer to the original PR: #4016

b/358385783

Change-Id: I0a9dd1b45d692d71dc681a196f349bcf53ab72fa

Co-authored-by: Ying Yu <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and yuying-y authored Sep 3, 2024
1 parent 212be13 commit 3405ecb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion starboard/extension/loader_app_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ typedef enum class SlotSelectionStatus {
kRollBackFailedToCheckSabi = 9,
kRollBackFailedToLookUpSymbols = 10,
kEGLite = 11,
kMaxValue = kEGLite,
kLoadSysImgFailedToInitInstallationManager = 12,
kMaxValue = kLoadSysImgFailedToInitInstallationManager,
} SlotSelectionStatus;

typedef struct StarboardExtensionLoaderAppMetricsApi {
Expand Down
10 changes: 10 additions & 0 deletions starboard/loader_app/loader_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,17 @@ void SbEventHandle(const SbEvent* event) {
starboard::loader_app::LoadSlotManagedLibrary(
app_key, alternative_content, &g_cobalt_library_loader,
use_memory_mapped_file));

if (g_sb_event_func == NULL) {
SB_LOG(ERROR) << "Failed to initialize Installation Manager. Loading "
"system image instead.";
starboard::loader_app::RecordSlotSelectionStatus(
SlotSelectionStatus::kLoadSysImgFailedToInitInstallationManager);
LoadLibraryAndInitialize(alternative_content, use_memory_mapped_file);
}
}
// If g_sb_event_func is NULL at this point, the app has no choice but to
// crash.
SB_CHECK(g_sb_event_func);
}

Expand Down
6 changes: 4 additions & 2 deletions starboard/loader_app/slot_management.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ void* LoadSlotManagedLibrary(const std::string& app_key,
LibraryLoader* library_loader,
bool use_memory_mapped_file) {
// Initialize the Installation Manager.
SB_CHECK(ImInitialize(kMaxNumInstallations, app_key.c_str()) == IM_SUCCESS)
<< "Abort. Failed to initialize Installation Manager";
if (ImInitialize(kMaxNumInstallations, app_key.c_str()) != IM_SUCCESS) {
SB_LOG(ERROR) << "Abort. Failed to initialize Installation Manager";
return NULL;
}

// Roll forward if needed.
if (ImRollForwardIfNeeded() == IM_ERROR) {
Expand Down

0 comments on commit 3405ecb

Please sign in to comment.