Fix Android crashes caused by attempts to use unsupported DRMs#2009
Fix Android crashes caused by attempts to use unsupported DRMs#2009CastagnaIT merged 2 commits intoxbmc:Piersfrom
Conversation
📝 Kodiai Draft Review Summary
What ChangedConsider: Refactored DRM initialization on Android to check crypto scheme support before instantiation, preventing crashes from unsupported DRMs. Reviewed: core logic, docs Strengths
ObservationsImpact[CRITICAL] src/decrypters/DrmEngine.cpp (188-194): Shared DRM instance reused across multiple key systems [MAJOR] src/decrypters/DrmEngine.cpp (441-444): Race condition on shared DRM instance [MAJOR] src/decrypters/DrmEngine.cpp (176-184): Silent failure when all DRMs fail initialization Suggestions
Verdict🔴 Address before merging -- 3 blocking issue(s) found (CRITICAL/MAJOR) Review Details
|
ReviewMust Fix
Medium
Minor
|
|
@kodiai about your first draft review i have tried to address the reported issues please do another draft review |
kodiai responseGood progress on addressing the previous issues. Here's the status: Fixed Issues(1) std::string_view lifetime — The keySystem field in DRMInstance at src/decrypters/DrmEngineDefines.h:128 is now std::string instead of std::string_view, fixing the dangling reference issue when GetDrmConfigs() entries were used to reorder keysystems. (2) Adapter reuse logic — At src/decrypters/widevineandroid/WVDecrypter.cpp:69-83, adapters are now cached in m_wvAdapters map (defined at src/decrypters/widevineandroid/WVDecrypter.h:95) and reused by keysystem, preventing the crash from recreating MediaDrm objects with unsupported UUIDs. (3) isCryptoSchemeSupported check — At src/decrypters/widevineandroid/WVCdmAdapter.cpp:365-374, the static check is correctly used before instantiation. Remaining Issues(1) [CRITICAL] Mutable dependency — depends/android/libandroidjni/libandroidjni.txt:1 still points to a personal fork branch tarball ( (2) [MINOR] Adapter map not cleared — src/decrypters/widevineandroid/WVDecrypter.h:95 shows m_wvAdapters is never cleared in any destructor or dispose method. While shared_ptr lifetime management may handle cleanup, explicit clearing in a dispose/cleanup path would be more maintainable. Next StepThe main blocker is the mutable dependency URL. Once the libandroidjni PR is merged upstream, update the dependency to use a commit-pinned tarball from xbmc/libandroidjni. |
1b02bf5 to
88820e2
Compare
|
@kodiai i updated the PR code, please review |
kodiai responseGood work addressing the previous issues. The core fix looks solid - the Remaining Critical Issue (1) [critical] depends/android/libandroidjni/libandroidjni.txt:1 — Still points to mutable branch tarball Observations (2) [minor] src/decrypters/DrmEngine.cpp:104 — Early-return check (3) [info] src/decrypters/DrmEngine.cpp:113 — The comment says "ClearKey is set as last since real DRMs should be preferred" which aligns with the default priority order. All previously reported issues have been addressed. Once the dependency reference is fixed to point to a stable commit SHA, this should be ready. |
The Android DRM interface supports multiple key systems. Previously, we treated all of them as supported, which caused crashes when attempting to use a key system not supported by the device
ReviewMust Fix Missing JNI exception check after Minor
|
Description
The crash is caused from the construction of
CJNIMediaDrmwith unsupported UUID/Keysysteminputstream.adaptive/src/decrypters/widevineandroid/WVCdmAdapter.cpp
Lines 91 to 92 in f731fc1
this is because ISA assume that on android all UUIDs/keysystems are supported by default,
where instead is not so on all android devices
to solve the problem now DRMs are constructed all in one time
in order to check what KeySystems are supported from each DRM
and this require
isCryptoSchemeSupportedmethod support from JNIdepends from JNI PR: xbmc/libandroidjni#59
Motivation and context
i was testing playready videos on last NVIDIA Shield firmware and noticed that it causes Kodi to crash to launcher
by inspecting logcat looks like nvidia has removed PlayReady support from last firmware or they has broken the playready drm interface showing a bug regarding ISA
How has this been tested?
try play playready video on NVIDIA Shield with last firmware and instead of crashing, the playback is now stopped with a "DRM not supported" message
Screenshots (if appropriate):
Types of change
Checklist: