3

at the moment, I try to fix some accessibility bugs in electron. For that, I had tried to build electron from source. The source isn't edited or changed from me, so it is original.

I pulled the source from the official repo on GitHub, following the building instructions and I had used the client and so on.

Here is the output of my steps in the terminal under Mac OS X 10.15:

Christophers-MacBook-Pro:src chpross$ gn gen out/Testing --args="import(\"//electron/build/args/testing.gn\") $GN_EXTRA_ARGS"
Done. Made 11597 targets from 1978 files in 6073ms

Christophers-MacBook-Pro:src chpross$ ninja -C out/Testing electron
ninja: Entering directory `out/Testing'
[8992/26566] CXX obj/services/network/..._cpp_sources/udp_socket.mojom-shared.o^[9026/26566] CXX obj/services/network/...content_security_policy.mojom-shared.o^[9044/26566] CXX obj/services/video_ca...ed_cpp_sources/receiver.mojom-shared.o^[9047/26566] CXX obj/services/video_ca...ared_cpp_sources/device.mojom-shared.o^[9098/26566] CXX obj/v8/torque_generat...itializers/object-fromentries-tq-csa.o^[9160/26566] CXX obj/third_party/blink...nderer/core/inspector/generated/Page.o^[10130/26566] OBJCXX obj/components/vi...tal_context_provider/metal_api_proxy.o
FAILED: obj/components/viz/common/metal_context_provider/metal_api_proxy.o 
/Users/chpross/programmierung/electron-gn/src/electron/external_binaries/sccache ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/components/viz/common/metal_context_provider/metal_api_proxy.o.d -DVIZ_METAL_CONTEXT_PROVIDER_IMPLEMENTATION -DDCHECK_ALWAYS_ON=1 -D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -DCR_XCODE_VERSION=1120 -DCR_CLANG_REVISION=\"373424-64a362e7-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -DCR_LIBCXX_REVISION=361348 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBP_EXTERN=extern -DENABLE_IPC_FUZZER -DUSE_EGL -DSK_GL -DSK_HAS_PNG_LIBRARY -DSK_HAS_WEBP_LIBRARY -DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -DSK_HAS_JPEG_LIBRARY -DSK_SUPPORT_GPU=1 -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DSK_BUILD_FOR_MAC -DSK_METAL -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -I../.. -Igen -I../../third_party/libwebp/src -I../../third_party/skia -I../../third_party/boringssl/src/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/khronos -I../../gpu -I../../third_party/mesa_headers -fno-strict-aliasing -fstack-protector -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers -arch x86_64 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wextra-semi -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-sizeof-array-div -O2 -fno-omit-frame-pointer -gdwarf-4 -g1 -isysroot ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.10.0 -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -std=c++14 -stdlib=libc++ -fobjc-call-cxx-cdtors -Wobjc-missing-property-synthesis -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -include obj/components/viz/common/metal_context_provider/precompile.h-mm -c ../../components/viz/common/gpu/metal_api_proxy.mm -o obj/components/viz/common/metal_context_provider/metal_api_proxy.o
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'hasUnifiedMemory' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:353:27: note: property declared here
@property (readonly) BOOL hasUnifiedMemory API_AVAILABLE(macos(10.15), ios(13.0));
                          ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'location' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:368:40: note: property declared here
@property (readonly) MTLDeviceLocation location API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                                       ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'locationNumber' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:377:33: note: property declared here
@property (readonly) NSUInteger locationNumber API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                                ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'maxTransferRate' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:385:31: note: property declared here
@property (readonly) uint64_t maxTransferRate API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                              ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'barycentricCoordsSupported' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:421:64: note: property declared here
@property(readonly, getter=areBarycentricCoordsSupported) BOOL barycentricCoordsSupported API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                                                               ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'supportsShaderBarycentricCoordinates' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:423:27: note: property declared here
@property (readonly) BOOL supportsShaderBarycentricCoordinates API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                          ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'peerGroupID' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:753:31: note: property declared here
@property (readonly) uint64_t peerGroupID API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                              ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'peerIndex' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:760:31: note: property declared here
@property (readonly) uint32_t peerIndex API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                              ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'peerCount' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:766:31: note: property declared here
@property (readonly) uint32_t peerCount API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                              ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: auto property synthesis will not synthesize property 'counterSets' declared in protocol 'MTLDevice' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:782:60: note: property declared here
@property (readonly, nullable) NSArray<id<MTLCounterSet>>* counterSets API_AVAILABLE(macos(10.15)) API_UNAVAILABLE(ios);
                                                           ^
../../components/viz/common/gpu/metal_api_proxy.mm:578:1: note: add a '@synthesize' directive
@end
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: method 'supportsFamily:' in protocol 'MTLDevice' not implemented [-Werror,-Wprotocol]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:659:1: note: method 'supportsFamily:' declared here
- (BOOL)supportsFamily:(MTLGPUFamily)gpuFamily API_AVAILABLE(macos(10.15), ios(13.0));
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: method 'newCounterSampleBufferWithDescriptor:error:' in protocol 'MTLDevice' not implemented [-Werror,-Wprotocol]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:793:1: note: method 'newCounterSampleBufferWithDescriptor:error:' declared here
- (nullable id<MTLCounterSampleBuffer>) newCounterSampleBufferWithDescriptor:(MTLCounterSampleBufferDescriptor*)descriptor
^
../../components/viz/common/gpu/metal_api_proxy.mm:224:17: error: method 'sampleTimestamps:gpuTimestamp:' in protocol 'MTLDevice' not implemented [-Werror,-Wprotocol]
@implementation MTLDeviceProxy
                ^
../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h:803:1: note: method 'sampleTimestamps:gpuTimestamp:' declared here
-(void)sampleTimestamps:(NSUInteger *)cpuTimestamp
^
13 errors generated.
[10139/26566] CXX obj/v8/v8_initializers/code-stub-assembler.o
ninja: build stopped: subcommand failed.

So different ninja targets produces different errors. I thing this is to big for one question, so if someone need this errors, I can paste it in a pastebin. The source code is official, but the build failed, I had already restarted the system, cleaned the out-dir and so on. Hopefully someone know what's went wrong here.

2 Answers2

2

SDK incompability
Electron/Chromium wasn't compatible with MacOSX 10.15 SDK when you tried to build. The required version is 10.14 as pointed out by

$ gn args out/Testing --list --short|grep sdk
mac_sdk_min = "10.14"

opposing to the docs. Download it from an older XCode version or unofficially from GitHub via

svn checkout https://github.com/phracker/MacOSX-SDKs/tree/master/MacOSX10.14.sdk

and set it active for ninja, e.g. by including the path in src/electron/build/args/testing.gn via mac_sdk_path = "$path_to_sdk_folder". I reverted my changes (see original post) and deleted out/Testing, throwing away all compilation results. There might be a less destructive way to reset/recompile only affected files. Then regenerate the config via gn gen and restart compiling.

Unfortunately the error with v8_context_snapshot persists:

ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/mac:clang_x64)
FAILED: v8_context_snapshot.bin
python ../../build/gn_run_binary.py ./v8_context_snapshot_generator --output_file=v8_context_snapshot.bin
[1119/152748.970749:FATAL:protected_memory.h(218)] Check failed: SetMemoryReadWrite(&writers, &writers + 1).
0   v8_context_snapshot_generator       0x000000010eda4829 base::debug::CollectStackTrace(void**, unsigned long) + 9
1   v8_context_snapshot_generator       0x000000010ec88dd3 base::debug::StackTrace::StackTrace() + 19
2   v8_context_snapshot_generator       0x000000010ec9b869 logging::LogMessage::~LogMessage() + 233
3   v8_context_snapshot_generator       0x000000010f1337df base::AutoWritableMemory::AutoWritableMemory(void*, void*) + 239
4   v8_context_snapshot_generator       0x000000010f133421 MojoEmbedderSetSystemThunks(MojoSystemThunks const*) + 257
5   v8_context_snapshot_generator       0x000000010c135c16 main + 86
6   libdyld.dylib                       0x00007fff6a0ed3d5 start + 1

./v8_context_snapshot_generator failed with exit code -5
ninja: build stopped: subcommand failed.

The other option is to wait until upstream fixes it, which is already happening as pointed out here. Or implement the neccessary changes yourself with the first one following, but more are needed.


Original post

Chromium has a MTLDeviceProxy which

wraps all calls to an MTLDevice [and] reports progress to the GPU watchdog.

Unfortunately it lacks properties required for the MTLDevice protocol that Clang can't auto-synthesize.
So we synthesize them explicitly in components/viz/common/gpu/metal_api_proxy.mm:

@implementation MTLDeviceProxy
- (id)initWithDevice:(id<MTLDevice>)device {
  if (self = [super init]) {
    device_.reset(device, base::scoped_policy::RETAIN);
    libraryCache_ = std::make_unique<MTLLibraryCache>();
  }
  return self;
}

// add synthesized properties here
@synthesize hasUnifiedMemory;
@synthesize location;
@synthesize locationNumber;
@synthesize maxTransferRate;
@synthesize barycentricCoordsSupported;
@synthesize supportsShaderBarycentricCoordinates;
@synthesize peerGroupID;
@synthesize peerIndex;
@synthesize peerCount;
@synthesize counterSets;

Also three abstract methods are missing. Insert these three wrappers before the end:

PROXY_METHOD1(BOOL, supportsFamily, MTLGPUFamily)
PROXY_METHOD2_SLOW(nullable id<MTLCounterSampleBuffer>,
                   newCounterSampleBufferWithDescriptor,
                   MTLCounterSampleBufferDescriptor*,
                   error,
                   NSError**)
PROXY_METHOD2_SLOW(void,
               sampleTimestamps,
               NSUInteger *,
               gpuTimestamp,
               NSUInteger *)

#endif
#pragma clang diagnostic pop

I wonder how those properties and methods could have been forgotten and why this issue surfaces right now. Happy compiling!

cachius
  • 1,743
  • 1
  • 8
  • 21
  • so, thank you, but I thing the problem is bigger then I thought. I implemented the changes and now, it results in other errors, that some delegates are not implemented. Now in /components/storage_monitor/image_capture_device.mm. I don't know whether this are problems from electron, chromium or simple my machine/system – Christopher Nov 13 '19 at 19:14
  • Hi @Christopher I have the same problem here when I try to build chromium version 76.0.3809.146. Did you manage to resolve this ? – TonyG Nov 14 '19 at 10:26
  • @TonyG: no, I haven‘t found a solution. Maybe w e should open a bug report – Christopher Nov 14 '19 at 16:53
  • @Christopher To which problem you facing right now ..I manage to solve many of them. – TonyG Nov 15 '19 at 10:24
  • @TonyG: a problem with the v8_context_snapshot_generator. Something with protected_memory.h. – Christopher Nov 15 '19 at 22:26
  • @TonyG `[1/193] ACTION //tools/v8_context_snapshot:generate_v8_context_snapshot(//build/toolchain/mac:clang_x64) FAILED: v8_context_snapshot.bin python ../../build/gn_run_binary.py ./v8_context_snapshot_generator --output_file=v8_context_snapshot.bin [1119/094505.100689:FATAL:protected_memory.h(218)] Check failed: SetMemoryReadWrite(&writers, &writers + 1). [snipped stack trace] ./v8_context_snapshot_generator failed with exit code -5 ninja: build stopped: subcommand failed.` – cachius Nov 19 '19 at 08:49
1

Chromium seems to have updated its code for macOS 10.15. You can find the updated code here. https://github.com/chromium/chromium/commit/961e7821b9356445f48e5ce2c077c40c2c6b2309

Potter Dai
  • 26
  • 1
  • 1