Kodi Community Forum

Full Version: Kodi 14.2 crash with custom PVR client
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm developing a custom PVR client but currently it is crashing Kodi when PVR functionality is enabled and Kodi is restarted, causing it to show the logo repeatedly. To be able to start up Kodi I have to manually edit guisettings.xml and disable the PVRManager. It also crashes when I disable PVR on the GUI.
The Demo PVR client installed through the repository works without any issues but I downloaded and compiled the PVR addons from https://github.com/opdenkamp/xbmc-pvr-addons, changed the name of the Demo addon on it to Demo2 on the addon.xml file and installed it on my test machine and caused the same behaviour as described. So this seems to be related to the build environment.
For my PVR client I copied the Demo PVR client from the Git repository mentioned above, added the new directory into the make structure and compiled it along with the rest of the addons.
One of the tests I did with debugging info was enabling PVR (no crash), checked the EPG timeline, disabled PVR (Kodi crashed), Kodi then repeatedly crashed when restarting until I edited guisettings.xml manually and disabled PVR. I also had debugging active on my client so this is what I got:

Call sequence inside my PVR client, while Kodi was running:

GetPVRAPIVersion
GetGUIAPIVersion
ADDON_Create
GetAddonCapabilities
GetBackendName
GetConnectionString
GetBackendVersion
GetChannels
GetDriveSpace
GetChannelsAmount
GetDriveSpace
GetChannelsAmount
GetDriveSpace
GetChannelsAmount
GetDriveSpace
GetChannelsAmount
GetDriveSpace
GetChannelsAmount

Disabled PVR on the GUI, Kodi crashed, got this on kodi.log and on my client's debug output:

20:56:48 T:140450732844928 INFO: stopping PVRManager
20:56:48 T:140449361827584 DEBUG: Thread EPGUpdater 140449361827584 terminating
20:56:48 T:140450732844928 NOTICE: PVRManager - stopping
20:56:48 T:140449370220288 DEBUG: Thread PVRGUIInfo 140449370220288 terminating
20:56:48 T:140449387005696 DEBUG: Thread PVRManager 140449387005696 terminating
20:56:48 T:140449378612992 DEBUG: Thread PVRClient 140449378612992 terminating
20:56:48 T:140450732844928 DEBUG: PVR - Destroy - destroying PVR add-on 'TVServer PVR add-on:connected'
20:56:48 T:140450732844928 DEBUG: SECTION:UnloadDll(/storage/.kodi/addons/pvr.tvserver/TVServer.pvr)
20:56:48 T:140450732844928 DEBUG: Unloading: /TVServer.pvr

GetDriveSpace
GetChannelsAmount
ADDON_Destroy

While Kodi was restarting got this on kodi.log and on my client's debug output:

20:57:18 T:140264698013440 NOTICE: Thread PVRManager start, auto delete: false
20:57:18 T:140264689620736 NOTICE: Thread PVRClient start, auto delete: false
20:57:18 T:140264689620736 DEBUG: RegisterClient - registering add-on 'TVServer PVR Client'
20:57:18 T:140264689620736 DEBUG: Previous line repeats 1 times.
20:57:18 T:140264689620736 DEBUG: PVR - Create - creating PVR add-on instance 'TVServer PVR Client'
20:57:18 T:140264689620736 DEBUG: ADDON: Dll Initializing - TVServer PVR Client
20:57:18 T:140264689620736 DEBUG: SECTION:LoadDLL(/storage/.kodi/addons/pvr.tvserver/TVServer.pvr)
20:57:18 T:140264689620736 DEBUG: Loading: /storage/.kodi/addons/pvr.tvserver/TVServer.pvr

GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion
GetPVRAPIVersion (once for each crash)

I got the code for Kodi 14.1 and it seems to me that Kodi is crashing inside this piece of code on AddonDll.h

Code:
ADDON_STATUS status(ADDON_STATUS_UNKNOWN);
  CLog::Log(LOGDEBUG, "ADDON: Dll Initializing - %s", Name().c_str());
  m_initialized = false;

  if (!LoadDll() || !CheckAPIVersion())
    return ADDON_STATUS_PERMANENT_FAILURE;

  /* Allocate the helper function class to allow crosstalk over
     helper libraries */
  m_pHelpers = new CAddonCallbacks(this);

  /* Call Create to make connections, initializing data or whatever is
     needed to become the AddOn running */
  try
  {
    status = m_pDll->Create(m_pHelpers->GetCallbacks(), m_pInfo);
    if (status == ADDON_STATUS_OK)

since I see the message 'Dll initializing' on the log, my 'GetPVRAPIVersion' function is called on the client but not the 'ADDON_Create'. This is the code on the 'GetPVPAPIVersion', copied from the Demo source:

Code:
const char* GetPVRAPIVersion(void)
{
    Log("GetPVRAPIVersion");
    static const char *strApiVersion = XBMC_PVR_API_VERSION;
    return strApiVersion;
}

Another interesting difference between the code I compile from the Git PVR addon repository and the demo client from Kodi's repository is that the '.pvr' that runs properly (from Kodi's repository) has a dependency on 'libpthread' while my compiled code does not.

Any thoughts on what might be causing this ?

Test system: OpenElec 5.0.8, with Kodi 14.2
Dev system: Kubuntu 14.04
As I suspected the problem was a silly mistake; I didn't notice that the Git had two branches, 'master' using PVR API 1.9.4 and 'helix' using PVR API 1.9.2. and obviously I checked out the wrong one. I had changed the required version on addon.xml manually and didn't think more of it. Obviously Kodi 14.2 still provides PVR API 1.9.2 and as such an addon trying to use version 1.9.4 has issues.