I'm still suffering from the build/link issues, here I'm going to describe the problems I encountered. --- 1. Use `MediaPlayer` framework directly (**failed**) As we are still using 10.11 on the try server, which is an older SDK, we are not able to find `MediaPlayer` framework to link on that SDK version. 2. Declare `extern ... MPMediaItemPropertyXXX` (**failed**) Then I tried to define something following in `MediaPlayerWrapper.h` ``` extern NSString* const _Nullable MPMediaItemPropertyTitle; extern NSString* const _Nullable MPMediaItemPropertyArtist; extern NSString* const _Nullable MPMediaItemPropertyAlbumTitle; ``` On the linking stage, it would show the error of not being able to find those symbols. Those variables are originally defined in `MPMediaItem.h`, which look like that, ``` MP_EXTERN NSString * const MPMediaItemPropertyTitle // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *title MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyAlbumTitle MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); // filterable @property (nonatomic, readonly, nullable) NSString *albumTitle MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyArtist // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *artist MP_API(ios(7.0)); ``` So they are also not defined there, because I think `MP_EXTERN` is a term similar with `extern`? 3. Declare `MPMediaItemPropertyXXX` with linking (**failed**) So I was thinking about if that could be fixed by manually adding link option, such like [1], then I added following codes, [1] https://searchfox.org/mozilla-central/rev/7b40f0b246ad0b54975b1525811f2ad599b95f33/toolkit/library/moz.build#75-79 ``` LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyTitle"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyArtist"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyAlbumTitle"] ``` The result is that, I could pass the build, however, it failed immediately when I ran Firefox, the error is that, ``` dlopen(/Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL, 265): Symbol not found: _MPMediaItemPropertyAlbumTitle Referenced from: /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Expected in: flat namespace in /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Couldn't load XPCOM. ``` 4. import <MediaPlayer/MPMediaItem.h> on 12.2+ (**failed**) Then I thought probably I can't simply override the declaration for things using `MP_EXTERN`, I tried to import the header file directly. ``` #if defined(MAC_OS_X_VERSION_10_12_2) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2 #import <MediaPlayer/MPMediaItem.h> #endif ``` That allows me to pass build, and I could also start my Firefox without issue. However, when running to the code where first access to those `MPMediaItemPropertyXXX`, the problem would crash immediately with `EXC_BAD_ACCESS`. I used `lldb` to check if they are still dangering, but I can see they all have value, so I don't really understand this error. ``` (lldb) p MPMediaItemPropertyTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $0 = 0x00007fff8277d3e8 "title" (lldb) p MPMediaItemPropertyArtist warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $1 = 0x00007fff827802e8 "artist" (lldb) p MPMediaItemPropertyAlbumTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $2 = 0x00007fff82781ea8 "albumTitle" ``` 5. Declare and define `MPMediaItemPropertyXXX` Here I went to my last option, force to redefine them manually in `MediaPlayerWrapper.h` ``` #define MPMediaItemPropertyTitle @"title" #define MPMediaItemPropertyArtist @"artist" #define MPMediaItemPropertyAlbumTitle @"albumTitle" ``` Okay, this method allows me to build and run Firefox successfully on both the 10.12+ and the 10.11 machine on the try server. However, it would make my gTest fail on the 10.14 machine on the try server. I can successfully pass my gTest on my local environment, but on the 10.14 machine on the try server, it seems that I can't set the value to `MPNowPlayingInfoCenter`'s `nowPlayingInfo`.... Here is my implementation, which works well for me on Big Sur. But on the 10.14 machine on the try server, I can see the results in `DD` are correct, which means I set the value correctly into the local variable `nowPlayingInfo`. However, the results in `DD1` are all empty, which means `MPNowPlayingInfoCenter` didn't update its `nowPlayingInfo`. [2] [2] https://treeherder.mozilla.org/logviewer?job_id=322229528&repo=try&lineNumber=29394 ``` void MediaHardwareKeysEventSourceMacMediaCenter::SetMediaMetadata( const dom::MediaMetadataBase& aMetadata) { NSMutableDictionary* nowPlayingInfo = [NSMutableDictionary dictionary]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mTitle) forKey:MPMediaItemPropertyTitle]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mArtist) forKey:MPMediaItemPropertyArtist]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mAlbum) forKey:MPMediaItemPropertyAlbumTitle]; NSLog(@"DD | Title in=%s out=%@", NS_ConvertUTF16toUTF8(aMetadata.mTitle).get(), nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD | Artist=%@", nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD | Album=%@", nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); MPNowPlayingInfoCenter* center = (MPNowPlayingInfoCenter*)[mpNowPlayingInfoCenterClass defaultCenter]; center.nowPlayingInfo = nowPlayingInfo; NSLog(@"DD1 | Title=%@", center.nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD1 | Artist=%@", center.nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD1 | Album=%@", center.nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); } ```
Bug 1671626 Comment 8 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
I'm still suffering from the build/link issues, here I'm going to describe the problems I encountered. --- 1. Use `MediaPlayer` framework directly (**failed**) As we are still using 10.11 on the try server, which is an older SDK, we are not able to find `MediaPlayer` framework to link on that SDK version. 2. Declare `extern ... MPMediaItemPropertyXXX` (**failed**) Then I tried to define something following in `MediaPlayerWrapper.h` ``` extern NSString* const _Nullable MPMediaItemPropertyTitle; extern NSString* const _Nullable MPMediaItemPropertyArtist; extern NSString* const _Nullable MPMediaItemPropertyAlbumTitle; ``` On the linking stage, it would show the error of not being able to find those symbols. Those variables are originally defined in `MPMediaItem.h`, which look like that, ``` MP_EXTERN NSString * const MPMediaItemPropertyTitle // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *title MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyAlbumTitle MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); // filterable @property (nonatomic, readonly, nullable) NSString *albumTitle MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyArtist // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *artist MP_API(ios(7.0)); ``` So they are also not defined there, because I think `MP_EXTERN` is a term similar with `extern`? 3. Declare `MPMediaItemPropertyXXX` with linking (**failed**) So I was thinking about if that could be fixed by manually adding link option, such like [1], then I added following codes, [1] https://searchfox.org/mozilla-central/rev/7b40f0b246ad0b54975b1525811f2ad599b95f33/toolkit/library/moz.build#75-79 ``` LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyTitle"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyArtist"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyAlbumTitle"] ``` The result is that, I could pass the build, however, it failed immediately when I ran Firefox, the error is that, ``` dlopen(/Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL, 265): Symbol not found: _MPMediaItemPropertyAlbumTitle Referenced from: /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Expected in: flat namespace in /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Couldn't load XPCOM. ``` 4. import <MediaPlayer/MPMediaItem.h> on 12.2+ (**failed**) Then I thought probably I can't simply override the declaration for things using `MP_EXTERN`, I tried to import the header file directly. ``` #if defined(MAC_OS_X_VERSION_10_12_2) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2 #import <MediaPlayer/MPMediaItem.h> #endif ``` That allows me to pass build, and I could also start my Firefox without issue. However, when running to the code where first access to those `MPMediaItemPropertyXXX`, the problem would crash immediately with `EXC_BAD_ACCESS`. I used `lldb` to check if they are still dangering, but I can see they all have value, so I don't really understand this error. ``` (lldb) p MPMediaItemPropertyTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $0 = 0x00007fff8277d3e8 "title" (lldb) p MPMediaItemPropertyArtist warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $1 = 0x00007fff827802e8 "artist" (lldb) p MPMediaItemPropertyAlbumTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $2 = 0x00007fff82781ea8 "albumTitle" ``` 5. Declare and define `MPMediaItemPropertyXXX` (**failed only on the try server gTest**) Here I went to my last option, force to redefine them manually in `MediaPlayerWrapper.h` ``` #define MPMediaItemPropertyTitle @"title" #define MPMediaItemPropertyArtist @"artist" #define MPMediaItemPropertyAlbumTitle @"albumTitle" ``` Okay, this method allows me to build and run Firefox successfully on both the 10.12+ and the 10.11 machine on the try server. However, it would make my gTest fail on the 10.14 machine on the try server. I can successfully pass my gTest on my local environment, but on the 10.14 machine on the try server, it seems that I can't set the value to `MPNowPlayingInfoCenter`'s `nowPlayingInfo`.... Here is my implementation, which works well for me on Big Sur. But on the 10.14 machine on the try server, I can see the results in `DD` are correct, which means I set the value correctly into the local variable `nowPlayingInfo`. However, the results in `DD1` are all empty, which means `MPNowPlayingInfoCenter` didn't update its `nowPlayingInfo`. [2] [2] https://treeherder.mozilla.org/logviewer?job_id=322229528&repo=try&lineNumber=29394 ``` void MediaHardwareKeysEventSourceMacMediaCenter::SetMediaMetadata( const dom::MediaMetadataBase& aMetadata) { NSMutableDictionary* nowPlayingInfo = [NSMutableDictionary dictionary]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mTitle) forKey:MPMediaItemPropertyTitle]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mArtist) forKey:MPMediaItemPropertyArtist]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mAlbum) forKey:MPMediaItemPropertyAlbumTitle]; NSLog(@"DD | Title in=%s out=%@", NS_ConvertUTF16toUTF8(aMetadata.mTitle).get(), nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD | Artist=%@", nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD | Album=%@", nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); MPNowPlayingInfoCenter* center = (MPNowPlayingInfoCenter*)[mpNowPlayingInfoCenterClass defaultCenter]; center.nowPlayingInfo = nowPlayingInfo; NSLog(@"DD1 | Title=%@", center.nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD1 | Artist=%@", center.nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD1 | Album=%@", center.nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); } ```
I'm still suffering from the build/link issues, here I'm going to describe the problems I encountered. --- 1. Use `MediaPlayer` framework directly (**failed**) As we are still using 10.11 on the try server, which is an older SDK, we are not able to find `MediaPlayer` framework to link on that SDK version. 2. Declare `extern ... MPMediaItemPropertyXXX` (**failed**) Then I tried to define something following in `MediaPlayerWrapper.h` ``` extern NSString* const _Nullable MPMediaItemPropertyTitle; extern NSString* const _Nullable MPMediaItemPropertyArtist; extern NSString* const _Nullable MPMediaItemPropertyAlbumTitle; ``` On the linking stage, it would show the error of not being able to find those symbols. Those variables are originally defined in `MPMediaItem.h`, which look like that, ``` MP_EXTERN NSString * const MPMediaItemPropertyTitle // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *title MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyAlbumTitle MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); // filterable @property (nonatomic, readonly, nullable) NSString *albumTitle MP_API(ios(7.0)); MP_EXTERN NSString * const MPMediaItemPropertyArtist // filterable MP_API(ios(3.0), tvos(9.0), watchos(5.0), macos(10.12.2)); @property (nonatomic, readonly, nullable) NSString *artist MP_API(ios(7.0)); ``` So they are also not defined there, because I think `MP_EXTERN` is a term similar with `extern`? 3. Declare `MPMediaItemPropertyXXX` with linking (**failed**) So I was thinking about if that could be fixed by manually adding link option, such like [1], then I added following codes, [1] https://searchfox.org/mozilla-central/rev/7b40f0b246ad0b54975b1525811f2ad599b95f33/toolkit/library/moz.build#75-79 ``` LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyTitle"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyArtist"] LDFLAGS += ["-Wl,-U,_MPMediaItemPropertyAlbumTitle"] ``` The result is that, I could pass the build, however, it failed immediately when I ran Firefox, the error is that, ``` dlopen(/Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL, 265): Symbol not found: _MPMediaItemPropertyAlbumTitle Referenced from: /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Expected in: flat namespace in /Users/alastor/mozilla-dev/mozilla-central/obj-debug-x86_64-apple-darwin20.1.0/dist/NightlyDebug.app/Contents/MacOS/XUL Couldn't load XPCOM. ``` 4. import <MediaPlayer/MPMediaItem.h> on 12.2+ (**failed**) Then I thought probably I can't simply override the declaration for things using `MP_EXTERN`, I tried to import the header file directly. ``` #if defined(MAC_OS_X_VERSION_10_12_2) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2 #import <MediaPlayer/MPMediaItem.h> #endif ``` That allows me to pass build, and I could also start my Firefox without issue. However, when running to the code where first access to those `MPMediaItemPropertyXXX`, the problem would crash immediately with `EXC_BAD_ACCESS`. I used `lldb` to check if they are still dangling, but I can see they all have value, so I don't really understand this error. ``` (lldb) p MPMediaItemPropertyTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $0 = 0x00007fff8277d3e8 "title" (lldb) p MPMediaItemPropertyArtist warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $1 = 0x00007fff827802e8 "artist" (lldb) p MPMediaItemPropertyAlbumTitle warning: `this' is not accessible (substituting 0) (__NSCFConstantString *) $2 = 0x00007fff82781ea8 "albumTitle" ``` 5. Declare and define `MPMediaItemPropertyXXX` (**failed only on the try server gTest**) Here I went to my last option, force to redefine them manually in `MediaPlayerWrapper.h` ``` #define MPMediaItemPropertyTitle @"title" #define MPMediaItemPropertyArtist @"artist" #define MPMediaItemPropertyAlbumTitle @"albumTitle" ``` Okay, this method allows me to build and run Firefox successfully on both the 10.12+ and the 10.11 machine on the try server. However, it would make my gTest fail on the 10.14 machine on the try server. I can successfully pass my gTest on my local environment, but on the 10.14 machine on the try server, it seems that I can't set the value to `MPNowPlayingInfoCenter`'s `nowPlayingInfo`.... Here is my implementation, which works well for me on Big Sur. But on the 10.14 machine on the try server, I can see the results in `DD` are correct, which means I set the value correctly into the local variable `nowPlayingInfo`. However, the results in `DD1` are all empty, which means `MPNowPlayingInfoCenter` didn't update its `nowPlayingInfo`. [2] [2] https://treeherder.mozilla.org/logviewer?job_id=322229528&repo=try&lineNumber=29394 ``` void MediaHardwareKeysEventSourceMacMediaCenter::SetMediaMetadata( const dom::MediaMetadataBase& aMetadata) { NSMutableDictionary* nowPlayingInfo = [NSMutableDictionary dictionary]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mTitle) forKey:MPMediaItemPropertyTitle]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mArtist) forKey:MPMediaItemPropertyArtist]; [nowPlayingInfo setObject:nsCocoaUtils::ToNSString(aMetadata.mAlbum) forKey:MPMediaItemPropertyAlbumTitle]; NSLog(@"DD | Title in=%s out=%@", NS_ConvertUTF16toUTF8(aMetadata.mTitle).get(), nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD | Artist=%@", nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD | Album=%@", nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); MPNowPlayingInfoCenter* center = (MPNowPlayingInfoCenter*)[mpNowPlayingInfoCenterClass defaultCenter]; center.nowPlayingInfo = nowPlayingInfo; NSLog(@"DD1 | Title=%@", center.nowPlayingInfo[MPMediaItemPropertyTitle]); NSLog(@"DD1 | Artist=%@", center.nowPlayingInfo[MPMediaItemPropertyArtist]); NSLog(@"DD1 | Album=%@", center.nowPlayingInfo[MPMediaItemPropertyAlbumTitle]); } ```