0

[Catalyst] Bootstrap startup.

Several fixes required to get the iOS Catalyst build through startup:

- Fix path to the resource directory.
- Change DCHECK to LOG for UIImage resources that aren't found

Bug: 1326989
Change-Id: Ice88bef88d700325a19d07c5a4d2bdb463088680
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646432
Reviewed-by: Mark Cogan <marq@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mike Pinkerton <pinkerton@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1004872}
This commit is contained in:
Mike Pinkerton
2022-05-18 18:27:35 +00:00
committed by Chromium LUCI CQ
parent 6daaaf82fe
commit 7226a9f40e
3 changed files with 19 additions and 3 deletions

@ -115,17 +115,23 @@ bool PathProviderMac(int key, base::FilePath* result) {
return base::mac::GetUserDirectory(NSDesktopDirectory, result);
#endif
case base::DIR_ASSETS:
#if BUILDFLAG(IS_IOS)
#if BUILDFLAG(IS_IOS) && !TARGET_OS_MACCATALYST
// On iOS, the assets are located next to the module binary.
return PathService::Get(base::DIR_MODULE, result);
#else
if (!base::mac::AmIBundled()) {
return PathService::Get(base::DIR_MODULE, result);
}
#if TARGET_OS_MACCATALYST
*result = base::mac::MainBundlePath()
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Resources"));
#else
*result = base::mac::FrameworkBundlePath().Append(
FILE_PATH_LITERAL("Resources"));
#endif // TARGET_OS_MACCATALYST
return true;
#endif // BUILDFLAG(IS_IOS)
#endif // BUILDFLAG(IS_IOS) && !TARGET_OS_MACCATALYST
case base::DIR_CACHE:
return base::mac::GetUserDirectory(NSCachesDirectory, result);
default:

@ -9,6 +9,7 @@
#include <ostream>
#include "base/check.h"
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "components/crash/core/common/objc_zombie.h"
@ -76,7 +77,13 @@ void SwizzleUIImageImageNamed() {
if (![exceptions containsObject:imageName] &&
![imageName containsString:@".FAUXBUNDLEID."]) {
// TODO(crbug.com/1325334): Temporarily turn off DCHECK while bootstrapping
// Catalyst. Log the error to the console instead.
#if TARGET_OS_MACCATALYST
DLOG(ERROR) << "Missing image: " << base::SysNSStringToUTF8(imageName);
#else
DCHECK(image) << "Missing image: " << base::SysNSStringToUTF8(imageName);
#endif
}
return image;
};

@ -80,7 +80,10 @@ bool PathProvider(int key, base::FilePath* result) {
break;
case FILE_RESOURCES_PACK:
if (!base::PathService::Get(base::DIR_MODULE, &cur))
// Catalyst builds are packaged like macOS, with the binary and resource
// directories separate. On iOS they are all together in a single dir.
// base::DIR_ASSETS does the right thing on each platform.
if (!base::PathService::Get(base::DIR_ASSETS, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("resources.pak"));
break;