{"record":{"id":"3227a57e330bcd50","repo":"wailsapp/wails","slug":"element-has-zero-size-is-it-hidden-target","errorCode":null,"errorMessage":"element has zero size (is it hidden?): ' + target.selector","messagePattern":"element has zero size \\(is it hidden\\?\\): ' \\+ target\\.selector","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/pkg/application/mcp_inject.js","lineNumber":294,"sourceCode":"            },\n        };\n        if ('value' in el && typeof el.value === 'string') description.value = el.value.slice(0, 500);\n        if (el.disabled) description.disabled = true;\n        if (el.href) description.href = el.href;\n        return description;\n    }\n\n    // Resolve {selector} or {x, y} into concrete viewport coordinates,\n    // scrolling selector targets into view first.\n    async function resolveTarget(target) {\n        if (target && target.selector) {\n            const el = document.querySelector(target.selector);\n            if (!el) throw new Error('no element matches selector: ' + target.selector);\n            el.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' });\n            await nextFrame();\n            const rect = el.getBoundingClientRect();\n            if (rect.width === 0 && rect.height === 0) {\n                throw new Error('element has zero size (is it hidden?): ' + target.selector);\n            }\n            const point = clampToViewport(rect.x + rect.width / 2, rect.y + rect.height / 2);\n            return { x: Math.round(point.x), y: Math.round(point.y), el };\n        }\n        if (target && typeof target.x === 'number' && typeof target.y === 'number') {\n            const point = clampToViewport(target.x, target.y);\n            return { x: Math.round(point.x), y: Math.round(point.y), el: null };\n        }\n        throw new Error('target requires a selector or x/y coordinates');\n    }\n\n    const BUTTONS = { left: 0, middle: 1, right: 2 };\n    const BUTTON_MASKS = { 0: 1, 1: 4, 2: 2 };\n\n    function focusTarget(el) {\n        const focusable = el && el.closest\n            ? el.closest('input, textarea, select, button, a[href], [tabindex], [contenteditable]')\n            : null;","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v3/pkg/application/mcp_inject.js#L276-L312","documentation":"CoInitializeEx initializes COM on the current thread with a concurrency model (e.g. COINIT_APARTMENTTHREADED). The w32 wrapper panics with a distinct message per failure HRESULT; E_INVALIDARG means the dwCoInit flags passed are not a valid combination. Valid values are COINIT_APARTMENTTHREADED or COINIT_MULTITHREADED (mutually exclusive), optionally ORed with COINIT_DISABLE_OLE1DDE, COINIT_SPEED_OVER_MEMORY. Passing both apartment flags, an undefined bit, or a garbage uintptr triggers this.","triggerScenarios":"Passing COINIT_APARTMENTTHREADED|COINIT_MULTITHREADED together; computing flags dynamically and including bits not in the legal set; porting code that used a stale constant value from another package with different numbering.","commonSituations":"Mixing COM flag constants from different Go Windows packages (e.g. golang.org/x/sys/windows vs a vendored copy) where numeric values or extra bits differ; a typo'd hex literal in hand-written flags.","solutions":["Pass exactly one apartment model flag, e.g. w32.COINIT_APARTMENTTHREADED, using constants from the same w32 package.","If flags come from config, validate them against the known set before calling.","Check for accidental OR of both apartment flags in code that 'falls back' between models — COM requires picking one per thread.","Compare against a known-good call such as the one in v3/pkg/w32/taskbar.go which uses COINIT_APARTMENTTHREADED."],"exampleFix":"// before\ncoinit := COINIT_APARTMENTTHREADED | COINIT_MULTITHREADED // invalid combo -> panic\nCoInitializeEx(uintptr(coinit))\n\n// after\nCoInitializeEx(COINIT_APARTMENTTHREADED)","handlingStrategy":"validation","validationCode":"func validCoInitFlags(f uintptr) bool {\n\tapartment := f & (w32.COINIT_APARTMENTTHREADED | w32.COINIT_MULTITHREADED)\n\tif apartment != w32.COINIT_APARTMENTTHREADED && apartment != w32.COINIT_MULTITHREADED {\n\t\treturn false\n\t}\n\treturn f & ^(w32.COINIT_APARTMENTTHREADED|w32.COINIT_MULTITHREADED|\n\t\tw32.COINIT_DISABLE_OLE1DDE|w32.COINIT_SPEED_OVER_MEMORY) == 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import COM constants from a single package to avoid mismatched values.","Pick exactly one apartment model per thread.","Never build flags from unvalidated external input."],"tags":["windows","com","threading","syscall","panic"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}