shaka-project / shaka-player-embedded

Shaka Player in a C++ Framework
Apache License 2.0
239 stars 62 forks source link

Error using widevine + shaka player in release #183

Open franciscocarodiaz opened 3 years ago

franciscocarodiaz commented 3 years ago

We have a problem only when we test the app in a real device. we get this error trying ro reproduce a content with DRM: "Got Shaka Player Error: Unable to find object." This error is displayed after load the url. The network filter is not reached and the error is displayed before.

We dont received another message and this is all we have.

We think that the error is generating shaka version from widevine: ../configure --ios --cpu arm64 --release --eme-impl ~/libs/widevine_prebuilt_cdm/shaka_plugin/release_cdm.json

This output is displayed after creating shaka-player version:

[695/1041] CXX obj/eme_plugins/widevine_implementation_factory.o In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation_factory.cc:5: In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.h:13: ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:18: warning: [chromium-style] Overriding method must be marked with 'override' or 'final'. virtual ~Cdm() {} ^ override ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:3: warning: [chromium-style] 'virtual' will be redundant; 'override' implies 'virtual'. virtual ~Cdm() {} ^~~~ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor. struct ClientInfo { ^ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor. ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:586:5: warning: [chromium-style] Complex constructor has an inlined body. InputBuffer() ^ 5 warnings generated. [697/1041] CXX obj/eme_plugins/widevine_implementation.o ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.cc:130:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] case widevine::Cdm::kUnexpectedError: ^ ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.cc:130:5: note: insert 'FALL_THROUGH_INTENDED;' to silence this warning case widevine::Cdm::kUnexpectedError: ^ FALL_THROUGH_INTENDED; ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.cc:130:5: note: insert 'break;' to avoid fall-through case widevine::Cdm::kUnexpectedError: ^ break; In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.cc:3: In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/widevine_implementation.h:13: ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:18: warning: [chromium-style] Overriding method must be marked with 'override' or 'final'. virtual ~Cdm() {} ^ override ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:3: warning: [chromium-style] 'virtual' will be redundant; 'override' implies 'virtual'. virtual ~Cdm() {} ^~~~ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor. struct ClientInfo { ^ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor. ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:586:5: warning: [chromium-style] Complex constructor has an inlined body. InputBuffer() ^ 6 warnings generated. [706/1041] CXX obj/eme_plugins/cdm_host.o In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/cdm_host.cc:8: In file included from ../shaka/src/core/js_manager_impl.h:24: In file included from ../shaka/include/shaka/js_manager.h:21: In file included from ../shaka/include/shaka/asyncresults.h:23: ../shaka/include/shaka/variant.h:227:41: warning: unused parameter 'i' [-Wunused-parameter] void copy(const union& other, sizet i) { ^ ../shaka/include/shaka/variant.h:232:36: warning: unused parameter 'i' [-Wunused-parameter] void move(union&& other, size_t i) { ^ ../shaka/include/shaka/variant.h:256:21: warning: unused parameter 'i' [-Wunused-parameter] void reset(sizet i) { ^ ../shaka/include/shaka/variant.h:261:43: warning: unused parameter 'i' [-Wunused-parameter] bool equals(const union& other, size_t i) const { ^ In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/cdm_host.cc:8: In file included from ../shaka/src/core/js_manager_impl.h:24: In file included from ../shaka/include/shaka/js_manager.h:23: In file included from ../shaka/include/shaka/net.h:26: ../shaka/include/shaka/optional.h:254:35: warning: unused parameter 'opt' [-Wunused-parameter] bool operator<(const optional& opt, nullopt_t) { ^ ../shaka/include/shaka/optional.h:266:47: warning: unused parameter 'opt' [-Wunused-parameter] bool operator<=(nullopt_t, const optional& opt) { ^ ../shaka/include/shaka/optional.h:274:46: warning: unused parameter 'opt' [-Wunused-parameter] bool operator>(nullopt_t, const optional& opt) { ^ ../shaka/include/shaka/optional.h:278:36: warning: unused parameter 'opt' [-Wunused-parameter] bool operator>=(const optional& opt, nullopt_t) { ^ In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/cdm_host.cc:8: In file included from ../shaka/src/core/js_manager_impl.h:26: In file included from ../shaka/src/core/network_thread.h:21: In file included from ../shaka/src/core/ref_ptr.h:23: In file included from ../shaka/src/mapping/convert_js.h:28: In file included from ../shaka/src/mapping/backing_object.h:23: ../shaka/src/mapping/weak_js_ptr.h:114:34: warning: unused parameter 'tracer' [-Wunused-parameter] void Trace(memory::HeapTracer* tracer) const override { ^ In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/cdm_host.cc:3: In file included from ~/libs/widevine_prebuilt_cdm/shaka_plugin/cdm_host.h:11: ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:18: warning: [chromium-style] Overriding method must be marked with 'override' or 'final'. virtual ~Cdm() {} ^ override ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:369:3: warning: [chromium-style] 'virtual' will be redundant; 'override' implies 'virtual'. virtual ~Cdm() {} ^~~~ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor. struct ClientInfo { ^ ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:313:3: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor. ~/libs/widevine_prebuilt_cdm/lib/release/arm64_ios/widevine_cdm_secured_ios.framework/Headers/cdm.h:586:5: warning: [chromium-style] Complex constructor has an inlined body. InputBuffer() ^

TheModMaker commented 3 years ago

Please reply to or close your other issues. If this is the result of fixing those issues, you should post this as a comment instead of opening a new issue. New issues should be for completely different problems.

Can you post your source code or give some more info on how you're interacting with the API? Can you post runtime logs? Compile logs aren't useful for debugging runtime problems.

franciscocarodiaz commented 3 years ago

We are able to check just this ShakaPlayerError from console:

Error Domain=ShakaPlayerErrorDomain Code=0 "Unable to find object." UserInfo={NSLocalizedDescription=Unable to find object., ShakaPlayerErrorSeverityKey=0, ShakaPlayerErrorCategoryKey=0}

And this is the source code that we are using:

class PlayerViewController: BaseViewController, UIGestureRecognizerDelegate { var playerView: ShakaPlayerView? var player: ShakaPlayer?

override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true)

guard let shakaPlayer = try? ShakaPlayer() else {
    print("Error creating player")
    return
}

self.player = shakaPlayer
self.player?.add(self)
self.player?.client = self
let shakaPlayerView = ShakaPlayerView(player: self.player)
shakaPlayerView.frame = self.view.bounds
self.playerView = shakaPlayerView
self.containerPlayerView.addSubview(self.playerView!)

self.configureAndLoadAssetWithAutoplay()

}

func configureAndLoadAssetWithAutoplay(startTime: Double = 0.0) { var urlMedia = getMediaUrl() var license = getLicense()

self.player?.configure("drm.servers.com\\.widevine\\.alpha", with: license)

self.player?.logLevel = ShakaPlayerLogLevel.V2
self.player?.load(urlMedia,
                  withStartTime: startTime,
                  andBlock: { error in
                    if let error = error {
                        print("Error loading manifest: \(error.message)")
                    } else {
                        self.player?.currentTime = 0
                        self.player?.play()
                    }
                  })

}

}

extension PlayerViewController: ShakaPlayerClient { func onPlayer(_ player: ShakaPlayer, bufferingChange is_buffering: Bool) { if (is_buffering) { self.loadingIndicator.isHidden = false self.loadingIndicator.startAnimating() } else { self.loadingIndicator.isHidden = true self.loadingIndicator.stopAnimating() } }

func onPlayer(_ player: ShakaPlayer, error: ShakaPlayerError) { self.displayAlertAndExit(title: "Shaka Player Error", message: error.message) }

}

extension PlayerViewController: ShakaPlayerNetworkFilter { func stringArrayToData(stringArray: [String]) -> Data? { return try? JSONSerialization.data(withJSONObject: stringArray, options: []) } func onPlayer(_ player: ShakaPlayer, networkRequest request: ShakaPlayerRequest, of type: ShakaPlayerRequestType, with block: @escaping ShakaPlayerAsyncBlock) { if (type == ShakaPlayerRequestType.license) { request.headers[Globals.PlayerKeys.KEY_ACCESS_TOKEN] = token request.headers[Globals.PlayerKeys.KEY_DEVICE_ID] = xtvupdevice request.headers[Globals.PlayerKeys.KEY_EVENTID] = eventId // This cert.bin is the widevine from widevine if let data: Data = getFile(forResource: "cert", withExtension: "bin") { request.body = data } } block(nil) } func onPlayer( player: ShakaPlayer, networkResponse response: ShakaPlayerResponse, of type: ShakaPlayerRequestType, with block: @escaping ShakaPlayerAsyncBlock) { block(nil) }

}

niggeulimann commented 3 years ago

I faced the same error - directly on launch. In my case it has been caused by setting the logLevel directly after creating the player. shakaPlayer?.logLevel = .none

Maybe this raises the error in the release-version!? Removing it seems to fix it in my case...