JanDeDobbeleer/oh-my-posh · error

GetSessions: 0x%08x

Error message

GetSessions: 0x%08x

What it means

With the SessionManager in hand, queryMediaPlayer calls GetSessions to obtain the read-only vector view of active SMTC sessions. A non-zero HRESULT is wrapped as "GetSessions: 0x%08x" - the list of media sessions could not be fetched.

Source

Thrown at src/runtime/smtc_windows.go:268

	var asyncOp unsafe.Pointer
	if hr := comCall(factory, staticsRequestAsync, uintptr(unsafe.Pointer(&asyncOp))); hr != 0 {
		return nil, fmt.Errorf("RequestAsync: 0x%08x", hr)
	}
	defer comRelease(asyncOp)

	if err := awaitAsync(asyncOp); err != nil {
		return nil, fmt.Errorf("await RequestAsync: %w", err)
	}

	var manager unsafe.Pointer
	if hr := comCall(asyncOp, asyncOpGetResults, uintptr(unsafe.Pointer(&manager))); hr != 0 {
		return nil, fmt.Errorf("GetResults manager: 0x%08x", hr)
	}
	defer comRelease(manager)

	var sessions unsafe.Pointer
	if hr := comCall(manager, managerGetSessions, uintptr(unsafe.Pointer(&sessions))); hr != 0 {
		return nil, fmt.Errorf("GetSessions: 0x%08x", hr)
	}
	defer comRelease(sessions)

	var size uint32
	if hr := comCall(sessions, vectorViewGetSize, uintptr(unsafe.Pointer(&size))); hr != 0 {
		return nil, fmt.Errorf("get_Size: 0x%08x", hr)
	}

	for i := uint32(0); i < size; i++ {
		var session unsafe.Pointer
		if hr := comCall(sessions, vectorViewGetAt, uintptr(i), uintptr(unsafe.Pointer(&session))); hr != 0 {
			continue
		}
		info, ok := readMediaSession(session, player)
		comRelease(session)
		if ok {
			return info, nil
		}

View on GitHub (pinned to 0976794618)

Solutions

  1. Retry the prompt render - often transient.
  2. Ensure RoInitialize/RoUninitialize are balanced (the code pins the OS thread for this) - an unbalanced state can poison subsequent calls.
  3. Check the HRESULT: E_POINTER/E_FAIL indicates a WinRT state problem; update or repair Windows media components.
  4. Disable other SMTC hooks (e.g. third-party media tools) that may interfere, then retest.
Defensive patterns

Strategy: fallback

Validate before calling

// Gate on environment before calling
if runtime.GOOS != "windows" { skipMediaSegment() }

Try / catch

info, err := env.QueryMediaPlayer(player)
if err != nil && strings.Contains(err.Error(), "GetSessions") {
    return templateWithoutMedia // omit media segment, keep prompt rendering
}

Prevention

When it happens

Trigger: The managerGetSessions vtable call returns a failing HRESULT, e.g. because the manager pointer is stale or the WinRT object rejected the call (apartment/threading mismatch).

Common situations: Calling from a thread whose COM apartment was torn down; Windows builds where the media session infrastructure is disabled; corrupted media stack after an audio driver crash.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/456710dc1952914f. Report an issue: GitHub.