Skip to content

Conversation

@Kate6
Copy link

@Kate6 Kate6 commented Nov 25, 2025

Description

Two small fixes to UPnP.

Motivation and context

(1) On Android, UPnP was dying if the app was navigated away from and then resumed.
(2) Kodi wasn't handling the resume point for UPnP objects when playback was stopped consistently.

How has this been tested?

What is the effect on users?

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@garbear garbear added Type: Fix non-breaking change which fixes an issue v22 Piers Component: UPnP Platform: Android labels Nov 25, 2025
@garbear garbear added this to the Piers 22.0 Alpha 3 milestone Nov 25, 2025
@garbear
Copy link
Member

garbear commented Nov 29, 2025

@Kate6 thanks for the fixes. It doesn't look like any upnp devs are around for review. It might help if you complete the PR template, such as with more details about the fixes, why they're needed, and how they've been tested. Try to target a dev unfamiliar with upnp, because that's pretty much all who could review this.

@garbear
Copy link
Member

garbear commented Dec 15, 2025

@claude review this please

@claude
Copy link

claude bot commented Dec 15, 2025

Claude finished @garbear's task in 1m 22s —— View job


Code Review Complete ✓

I've reviewed both UPnP fixes in this PR. Overall, these are well-targeted bug fixes that address real issues. Here's my detailed analysis:


Fix #1: Android UPnP Service Restart on Resume ✅

File: xbmc/application/Application.cpp:1551

Change:

case TMSG_RESUMEAPP:
{
  m_ServiceManager->GetNetwork().NetworkMessage(CNetworkBase::SERVICES_UP, 0);  // Added
  CGUIComponent* gui = CServiceBroker::GetGUI();
  ...

Analysis:

  • Problem Addressed: When Android apps are backgrounded and resumed, network services (including UPnP) weren't being restarted
  • Solution: Calls NetworkMessage(SERVICES_UP) which triggers m_services->Start() in Network.cpp:216
  • Correctness: ✅ The fix mirrors the pattern used in ProfileManager.cpp:396 where network services are explicitly started
  • Impact: Low risk - this is a standard service restart pattern already used elsewhere in the codebase

Potential Concerns:

  • No obvious issue, but consider: Could calling SERVICES_UP when services are already running cause problems? Looking at the network services implementation, it should handle this gracefully, but it might be worth verifying that m_services->Start() is idempotent.

Fix #2: UI Update After Saving UPnP File State ✅

File: xbmc/utils/SaveFileStateJob.cpp:57-66

Change:
After successfully saving UPnP file state, the code now sends a GUI update message to refresh the UI with the new resume point.

Analysis:

  • Problem Addressed: When playback stops on UPnP content, the UI wasn't updating to show the new resume point
  • Solution: Creates an updated CFileItem with the correct resume point and path, then sends GUI_MSG_UPDATE_ITEM to the window manager
  • Pattern Consistency: ✅ This mirrors the existing pattern at lines 179-196 for non-UPnP items
  • Path Handling: ✅ Correctly handles both cases:
    • Uses original_listitem_url property if available (lines 60-61)
    • Falls back to progressTrackingFile (which should be the UPnP path) otherwise (line 63)

Implementation Quality:

  • Creates a copy (updatedItem) rather than modifying the original - good practice
  • Updates the video info tag's resume point before sending the message
  • Uses std::make_shared<CFileItem> for the message parameter - correct smart pointer usage

Minor Observation:
The comment on line 63 is helpful: "fallback to progressTrackingFile which should be the upnp path"


Overall Assessment

Strengths:

  1. Both fixes are minimal, targeted changes that address specific bugs
  2. Code follows existing patterns in the codebase (consistency)
  3. No breaking changes or API modifications
  4. Proper use of existing infrastructure (NetworkMessage, GUI messages)

Code Quality:

  • Clean, readable code
  • Appropriate comments
  • No memory leaks or resource issues
  • Follows RAII principles with smart pointers

Testing Recommendations:
Since the PR template mentions testing wasn't fully documented, I'd recommend testing:

  1. Fix XBMC core Portuguese translation based on English commit 1ee638d8b22a3a5440e57a9384590558925e12ef #1: On Android, verify UPnP servers are discoverable after backgrounding/resuming the app
  2. Fix Confluence Portuguese strings translation update #2: Play a UPnP video, stop partway through, verify the resume point appears in the UI immediately

Approval:
These are solid bug fixes that improve UPnP reliability. The code is safe, follows existing patterns, and addresses real user-facing issues. I see no blockers for merging.


@garbear
Copy link
Member

garbear commented Dec 16, 2025

@Kate6 now that we have both squishy and robot approvals, can you apply the Jenkins patch? Then we'll merge.


case TMSG_RESUMEAPP:
{
m_ServiceManager->GetNetwork().NetworkMessage(CNetworkBase::SERVICES_UP, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is likely a better place for this (CApplication shouldn't call into network) but it's consistent with the current architecture so it's fine here for now.

@garbear
Copy link
Member

garbear commented Dec 16, 2025

@Kate6 We want CI to be happy between each commit, so can you squash the third commit into the first and force-push? Jenkins checks each commit for style-correctness so that if one is reverted, we don't get an in-between result.

@garbear
Copy link
Member

garbear commented Dec 16, 2025

@Kate6 Oops, you squashed your two fixes. You can recover your work here: https://github.com/Kate6/xbmc/commits/b044731e9f3f59183d7cc6692915d3d483bb9815

Then the third commit should be squashed into the first.

After saving the file state of a UPnP item, the UI was not always
reflecting the new resume point. This change ensures the UI is
updated by sending a GUI_MSG_UPDATE_ITEM message with the updated
file item information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants