Skip to content

Fix shutdown ordering for OOP IPlugin Release - #2171

Open
nxtum wants to merge 12 commits into
rdkcentral:masterfrom
nxtum:oop-shutdown-iplugin-order
Open

Fix shutdown ordering for OOP IPlugin Release#2171
nxtum wants to merge 12 commits into
rdkcentral:masterfrom
nxtum:oop-shutdown-iplugin-order

Conversation

@nxtum

@nxtum nxtum commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fix shutdown of plugins where IPlugin itself is hosted by ThunderPlugin OOP

The failing release was the host releasing the plugin interface itself

ReleaseInterfaces() could terminate _connection before releasing currentIF
ThunderPlugin could call WorkerPool:Stop() from the ServiceAdministrator callback when the final IPlugin object was destroyed

That allowed the ThunderPlugin process to close while the host was still waiting for the remote currentIF->Release() to complete...

Copilot AI review requested due to automatic review settings July 10, 2026 22:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nxtum
nxtum requested a review from sebaszm July 13, 2026 12:26
Copilot AI review requested due to automatic review settings July 20, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 20, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
PR Preview Action v1.1.1-25-g59e77e4
🛫 Deployed preview to https://rdkcentral.github.io/Thunder/pr-preview/pr-2171/
on branch gh-pages at 2026-07-29 08:41 UTC

Copilot AI review requested due to automatic review settings July 20, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 22, 2026 18:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread Source/ThunderPlugin/Process.cpp
Comment thread docs/plugin/execution-modes/outofprocess.md Outdated
@sebaszm
sebaszm requested review from MFransen69 and removed request for sebaszm July 24, 2026 14:21
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 27, 2026 13:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 28, 2026 12:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

docs/plugin/execution-modes/outofprocess.md:12

  • Docs: this section uses "out of process" while the rest of the document uses the hyphenated "out-of-process". Using consistent terminology improves readability and avoids confusion with the established term used elsewhere in this page.
It is also possible to run the full plugin out of process. This allows a plugin to be hosted by `ThunderPlugin` even if it was not split or specifically designed for the traditional OOP plugin model. In this mode, `PluginHost::IPlugin` itself is hosted by `ThunderPlugin`.

@VeithMetro VeithMetro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nxtum I get the idea, and I think it looks good in general, but I am just wondering about one corner case:

Since _parent. Stop() is no longer called in Dispatch() for a fully OOP plugins, what if the connection was no longer valid for some reason, and then we would not get to _connection->Terminate() in ReleaseInterfaces()?

@nxtum

nxtum commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@nxtum I get the idea, and I think it looks good in general, but I am just wondering about one corner case:

Since _parent. Stop() is no longer called in Dispatch() for a fully OOP plugins, what if the connection was no longer valid for some reason, and then we would not get to _connection->Terminate() in ReleaseInterfaces()?

Well, there are 2 diff cleanup paths

  1. _parent.Stop() from Dispatch(), which is on the thunder plugin side. It stops the workerpool when the last obj is released

  2. _connection->Terminate() on the Thunder side

When Thunder first creates this OOP plugin, it stores the remote connection

https://github.com/rdkcentral/Thunder/blob/master/Source/Thunder/PluginServer.h#L1343-L1354

https://github.com/rdkcentral/Thunder/blob/master/Source/com/Communicator.h#L1359

This returns a ref counted connection obj, which is owned until its released by ReleaseInterfaces

So from my understanding, during the deactive part, when you terminate this _connection at the end, it will still exist as its still a stored connection even if the channel was closed

@nxtum

nxtum commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

For a "traditional" OOP plugin, Stop() is still called. Only when you run a plugin that was not designed for OOP you cannot Stop() because the remote object is Iplugin itself, thunder could still be releasing IPlugin proxy. So if you were to stop there, there is a race, which is why you get:

[Error]: Could not remote release the Proxy for Interface [0x30]

Copilot AI review requested due to automatic review settings July 28, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 29, 2026 08:40

@VeithMetro VeithMetro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add an ASSERT like we discussed, and please do a smoke test to see it does not fire 😄

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

docs/plugin/execution-modes/outofprocess.md:14

  • Use consistent hyphenation for execution modes: this section uses “out of process” / “in process”, while the rest of the docs use “out-of-process” / “in-process”. Keeping the terminology consistent improves searchability and avoids ambiguity.
It is also possible to run the full plugin out of process. This allows a plugin to be hosted by `ThunderPlugin` even if it was not split or specifically designed for the traditional OOP plugin model. In this mode, `PluginHost::IPlugin` itself is hosted by `ThunderPlugin`.

This is mainly useful as a development and debugging option. For example, it can be used to isolate leaks, crashes, or shutdown behavior in plugins that were originally designed to run in process.

Copilot AI review requested due to automatic review settings July 29, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 29, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nxtum

nxtum commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

added an ASSERT that would fire if:

  • plugin is OOP
  • there is a plugin interface to release
  • but there is no stored connection

@nxtum
nxtum requested a review from VeithMetro July 29, 2026 10:22
@VeithMetro

Copy link
Copy Markdown
Contributor

And just to make sure, you did smoke test with this ASSERT and it does not fire? 😄

@nxtum

nxtum commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

And just to make sure, you did smoke test with this ASSERT and it does not fire? 😄

We will find out in production 😄

I tested spamming activate/deactivate on multiple in process and oop plugins and didn't fire, so should be good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants