Skip to content

fix: stabilize PPT slideshow state sync on transient COM states#394

Merged
CJKmkp merged 1 commit intobetafrom
codex/fix-powerpoint-slow-response-and-crashes
Mar 5, 2026
Merged

fix: stabilize PPT slideshow state sync on transient COM states#394
CJKmkp merged 1 commit intobetafrom
codex/fix-powerpoint-slow-response-and-crashes

Conversation

@CJKmkp
Copy link
Member

@CJKmkp CJKmkp commented Mar 5, 2026

Motivation

  • Reduce transient errors and UI/state desync when PowerPoint enters slideshow mode, which can trigger COM HRESULT 0x80048240 (no active presentation/document window) and cause controls to disappear or the app to hang.
  • Avoid accessing ActiveWindow/ActivePresentation during slideshow transitions where those COM properties may be temporarily unavailable, preventing cascade failures and slow/blocked behavior.

Description

  • Add detection helper IsNoActivePresentationOrWindowHResult to treat 0x80048240 as a transient condition rather than a hard error.
  • Make UpdateCurrentPresentationInfo slideshow-aware by adding parameters preferSlideShowWindow and knownSlideShowWindow so slideshow events can provide a stable SlideShowWindow context.
  • Introduce TryGetActivePresentation that first attempts ActivePresentation and falls back to reading the Presentation from a SlideShowWindow (or the first SlideShowWindows entry) when ActivePresentation throws 0x80048240.
  • Update OnSlideShowBegin and OnSlideShowNextSlide to pass the event SlideShowWindow into UpdateCurrentPresentationInfo, and relax COM-exception logging to ignore the transient 0x80048240 case.

Testing

  • Ran dotnet --version in the current environment to attempt a build/runtime check, which failed with dotnet: command not found so no automated .NET tests could be executed here.

Codex Task

@CJKmkp CJKmkp merged commit 9802ab9 into beta Mar 5, 2026
1 check passed
@CJKmkp CJKmkp deleted the codex/fix-powerpoint-slow-response-and-crashes branch March 5, 2026 03:56
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32f1d95585

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +590 to +593
if (knownSlideShowWindow != null)
{
slideShowWindow = ssw[1];
if (slideShowWindow != null)
slideShowWindow = knownSlideShowWindow;
}

Choose a reason for hiding this comment

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

P1 Badge Avoid releasing the slideshow event window instance

When knownSlideShowWindow is provided, this branch stores the caller-owned event argument in slideShowWindow, and UpdateCurrentPresentationInfo later calls SafeReleaseComObject(slideShowWindow) in finally. In OnSlideShowBegin/OnSlideShowNextSlide, that means wn can be released before SlideShowBegin?.Invoke(wn) or SlideShowNextSlide?.Invoke(wn), so handlers that access COM members like wn.View may hit InvalidComObjectException during normal slideshow events.

Useful? React with 👍 / 👎.

Comment on lines +752 to +753
dynamic sswObj = slideShowWindow;
return sswObj.Presentation;

Choose a reason for hiding this comment

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

P2 Badge Release COM references before returning presentation fallback

The fallback path in TryGetActivePresentation returns sswObj.Presentation directly without any finally cleanup for the temporary SlideShowWindows/SlideShowWindow COM objects created earlier in the method. Because this helper is now called on each presentation-state refresh, those unreleased COM references can accumulate and keep PowerPoint objects alive longer than expected, degrading stability over time.

Useful? React with 👍 / 👎.

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.

1 participant