# Known Bugs and Limitations

## Critical: Window Manipulation via IPC Crashes (wry 0.47.2 Bug)

**Status:** UNFIXED - Library Bug
**Severity:** Critical
**Affected Version:** msger using wry 0.47.2

### Description

All window manipulation functions called via JavaScript IPC cause immediate crashes with the following error:

```
thread 'main' panicked at wry-0.47.2\src\webview2\mod.rs:812:58:
called `Result::unwrap()` on an `Err` value: http::Error(InvalidUri(InvalidFormat))
```

### Affected Functions

The following `window.msger` API functions are **DISABLED** to prevent crashes:

- ❌ `msger.toggleFullscreen()` - Crashes
- ❌ `msger.setFullscreen(enabled)` - Crashes
- ❌ `msger.minimize()` - Crashes
- ❌ `msger.maximize()` - Crashes
- ❌ `msger.setSize(width, height)` - Crashes
- ❌ `msger.setPosition(x, y)` - Crashes
- ❌ `msger.setAlwaysOnTop(enabled)` - Crashes
- ❌ `msger.setTitle(title)` - Crashes
- ❌ `msger.close(result)` - Crashes (ALL IPC is broken!)

### Working Functions

These functions still work because they don't use IPC:

- ✅ `msger.saveData(key, value)` - Uses localStorage only
- ✅ `msger.loadData(key, defaultValue)` - Uses localStorage only
- ✅ `msger.removeData(key)` - Uses localStorage only
- ✅ `msger.clearData()` - Uses localStorage only
- ✅ `msger.isAvailable()` - Pure JavaScript check
- ✅ `msger.testHello()` - Pure JavaScript test

**Note:** Data saved with `saveData()` **persists across restarts** because it uses localStorage!

### Workarounds

#### Window Manipulation
Use **CLI arguments** when launching msger instead of JavaScript API:

```bash
# Fullscreen
node cli.js -url page.html -fullscreen

# Window size
node cli.js -url page.html -size 1024,768

# Window position
node cli.js -url page.html -pos 100,100

# Always on top
node cli.js -url page.html -alwaysOnTop

# Window title
node cli.js -url page.html -title "My App"
```

#### Fullscreen Toggle
Use the **F11 keyboard shortcut** instead of JavaScript:
- Press F11 to enter fullscreen
- Press F11 again or Esc to exit fullscreen

This works because F11 is handled at the native window level, not through IPC.

### Technical Details

**Root Cause:**
The wry 0.47.2 library has a bug where window manipulation operations trigger an internal code path that tries to parse something as an HTTP URI. When this parse fails, it panics in FFI (Foreign Function Interface) code that cannot unwind, causing an immediate abort.

**Why catch_unwind Doesn't Work:**
The panic occurs in `extern "C"` function boundaries (FFI with WebView2 COM interface), which cannot be unwound across. The `std::panic::catch_unwind` wrapper we added catches Rust panics, but not panics in FFI code marked as "cannot unwind".

**Crash Location:**
`C:\Users\Bob\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wry-0.47.2\src\webview2\mod.rs:812:58`

### Potential Solutions

1. **Update wry** - Check if newer versions (0.48+) have fixed this issue
2. **Use tauri** - Switch to the full Tauri framework which may have better WebView2 integration
3. **Alternative WebView** - Consider using a different WebView library
4. **Native UI** - Build a native UI instead of HTML/JavaScript for window controls

### Testing

Use the provided test page to verify which functions work:

```bash
node cli.js -url test-msger-functions.html -size 800,900
```

All disabled functions will:
- Return `false`
- Log an error message to the console
- NOT crash the application

## Other Known Issues

### F11 Key Sometimes Ignored

**Status:** Under Investigation
**Severity:** Medium

F11 keyboard shortcut for fullscreen may be captured by WebView2 before reaching the window event handler.

**Workaround:** Launch with `-fullscreen` flag to start in fullscreen mode.

---

**Last Updated:** 2025-11-05
**msger Version:** 0.1.57
**wry Version:** 0.47.2
**tao Version:** 0.30
