Commit graph

82 commits

Author SHA1 Message Date
Lea Anthony
4dce80d887
fix(v3): revert goccy/go-json to stdlib encoding/json to fix Windows panic (#4859)
* fix(v3): warm up dialog types in go-json cache to prevent Windows panic

Add FileFilter, OpenFileDialogOptions, SaveFileDialogOptions, and
MessageDialogOptions to the init() warmup to prevent index out of bounds
panic on Windows when these types are first unmarshaled.

Fixes goccy/go-json#474 for Wails internal dialog types.

* fix(v3): revert goccy/go-json to stdlib encoding/json to fix Windows panic

goccy/go-json has a type address calculation bug on Windows that causes
index out of bounds panic when decoding user-defined types for the first time.

This reverts all runtime usages of goccy/go-json back to stdlib encoding/json.
Test and benchmark files are left unchanged.

Partially reverts PR #4843.
2026-01-05 08:26:35 +11:00
Lea Anthony
a06d55804c
perf(v3): optimize JSON processing and reduce allocations in hot paths (#4843)
* perf(v3): optimize JSON processing and reduce allocations in hot paths

- Switch to goccy/go-json for method binding, events, and HTTP transport
  (21-63% faster, 40-60% less memory for method calls)
- Optimize BoundMethod struct layout to reduce padding (144 -> 136 bytes)
- Cache isVariadic flag at registration to avoid reflect call per invocation
- Use stack-allocated buffer for method arguments (<=8 args)
- Optimize result collection to avoid slice allocation for single return values
- Use sync.Map for MIME cache to improve concurrent read performance
- Use buffer pool for HTTP transport request body reading
- Lazily allocate CloseNotify channel in content type sniffer
- Remove debug CSS logging from asset server
- Add comprehensive benchmark tests (build tag: bench)

Performance improvements for BoundMethod.Call:
- SimpleCall:   1290ns -> 930ns (28% faster), 240B -> 80B (67% less memory)
- ComplexCall:  10500ns -> 3900ns (63% faster), 1192B -> 1020B (14% less)
- VariadicCall: 3460ns -> 1600ns (54% faster), 512B -> 289B (44% less)

* perf(v3): add max size limit to buffer pool to prevent memory bloat

Buffers larger than 512KB are not returned to the pool, allowing GC
to reclaim memory after large requests (e.g., base64 encoded images).

* perf(v3): remove mimetype library dependency, saving ~208KB binary size

- Replace github.com/wailsapp/mimetype with expanded extension map + stdlib
- Expand MIME type map from 16 to 50+ common web formats (fonts, audio, video, etc.)
- Add comprehensive test suite validating MIME detection for all web formats
- Use http.DetectContentType as fallback for unknown extensions
- Actual binary size reduction: 1.2MB (11MB -> 9.8MB in test app)

* perf(v3): migrate all runtime code to goccy/go-json

Migrate remaining encoding/json usages to goccy/go-json in:
- pkg/application (android, darwin, ios, single_instance, webview_window)
- pkg/services (kvstore, notifications on all platforms)
- internal/assetserver/webview (request/response handling)
- internal/runtime and internal/capabilities

Note: encoding/json (110KB) remains in binary because:
1. goccy/go-json imports it for interface compatibility (json.Marshaler, etc.)
2. log/slog (stdlib) uses it for JSON output

The performance benefit is in the hot paths which now use the faster library.

* perf(v3): replace gopkg.in/ini.v1 with minimal .desktop file parser

Replace the gopkg.in/ini.v1 dependency with a purpose-built minimal parser
for Linux .desktop files.

The new parser:
- Only extracts the Exec key from [Desktop Entry] section (all we need)
- Follows the Desktop Entry Specification
- Has comprehensive test coverage (40 tests) including:
  - All major file managers (Nautilus, Dolphin, Thunar, PCManFM, Caja, Nemo)
  - Edge cases (UTF-8, special chars, comments, empty files, etc.)
  - Buffer limit handling

Binary size reduction: 45KB (10.22MB -> 10.18MB)

* perf(v3): remove samber/lo from runtime code, saving ~310KB binary size

Replace samber/lo with Go 1.21+ stdlib slices package and minimal internal
helpers in all runtime code paths. This removes 80 transitive dependencies
from the production binary.

Changes:
- Create internal/sliceutil package with Unique and FindMapKey helpers
- Replace lo.Without with slices.DeleteFunc in event handling
- Replace lo.Ternary with inline if/else in Windows code
- Replace lo.Uniq with sliceutil.Unique for feature flags
- Replace lo.FindKey with sliceutil.FindMapKey for method aliases
- Replace lo.Filter with slices.DeleteFunc in event listeners
- Replace lo.Must with inline panic in w32 package

Binary size: 10.18MB -> 9.87MB (~310KB / 3% reduction)

Note: CLI tools still use samber/lo since they don't affect
production binary size. The application_debug.go file also
retains lo usage as it has //go:build !production tag.

* fix: address CodeRabbit review comments

- Use application/x-typescript MIME type (not IANA-registered text/typescript)
- Fix potential panic in mimetype_stdlib_test.go for short MIME strings
- Use cached isVariadic flag in bindings_optimized_bench_test.go

* fix: initialize goccy/go-json decoder early to fix Windows test failure

On Windows, goccy/go-json's type address calculation can fail if the
decoder is first invoked during test execution rather than at init time.
Force early initialization by unmarshaling a []int during package init.

See: https://github.com/goccy/go-json/issues/474

* 📝 Add docstrings to `v3/performance-improvements` (#4844)

* fix: initialize goccy/go-json decoder early to fix Windows test failure

On Windows, goccy/go-json's type address calculation can fail if the
decoder is first invoked during test execution rather than at init time.
Force early initialization by unmarshaling a []int during package init.

See: https://github.com/goccy/go-json/issues/474

* 📝 Add docstrings to `v3/performance-improvements`

Docstrings generation was requested by @leaanthony.

* https://github.com/wailsapp/wails/pull/4843#issuecomment-3703472562

The following files were modified:

* `v3/internal/assetserver/common.go`
* `v3/internal/assetserver/content_type_sniffer.go`
* `v3/internal/assetserver/mimecache.go`
* `v3/internal/fileexplorer/desktopfile.go`
* `v3/internal/fileexplorer/fileexplorer_linux.go`
* `v3/internal/sliceutil/sliceutil.go`
* `v3/pkg/application/application_ios.go`
* `v3/pkg/application/bindings.go`
* `v3/pkg/application/ios_runtime_ios.go`
* `v3/pkg/w32/window.go`

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-01-02 07:03:36 +11:00
Lea Anthony
2e396bd48f fix(ios): correct service implementation pattern for dock and notifications
The iOS service stubs were importing a non-existent package
`github.com/wailsapp/wails/v3/pkg/services` and using an incompatible
interface pattern.

This fix rewrites both files to follow the same pattern as other platforms
(Linux, Windows, Darwin):
- Implement the internal platformDock/platformNotifier interfaces
- Provide New() functions returning *DockService/*NotificationService
- Stub all required interface methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 06:01:38 +11:00
Lea Anthony
873848a077 Merge iOS support from v3-alpha-feature/ios-support
This commit integrates iOS platform support for Wails v3, adapting the
iOS-specific code to work with the new transport layer architecture.

Key changes:
- Add iOS-specific application, webview, and runtime files
- Add iOS event types and processing
- Add iOS examples and templates
- Update messageprocessor to handle iOS requests
- Move badge_ios.go to dock package

Note: The iOS branch was based on an older v3-alpha and required
significant conflict resolution due to the transport layer refactor
(PR #4702). Some iOS-specific code may need further adaptation:
- processIOSMethod needs to be implemented with new RuntimeRequest signature
- iOS event generation in tasks/events/generate.go needs updating

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 18:34:21 +11:00
Zach Botterman
48e3bd3dd4
[v3] bugfix/windows linux notifications (#4450)
* fix windows encoding

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-07-30 12:40:58 +00:00
Zach Botterman
23bf36d36f
[v3] improve service names for js/ts bindings (#4405)
* name services

* update badge service with new app api

* update examples

* add dist dirs

* update changelog

* fix up examples

* Fix changelog

---------

Co-authored-by: Zach <zach@Zachs-MacBook-Pro-2.local>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-07-25 09:23:22 +10:00
popaprozac
66ba876a65 better errors 2025-04-22 16:21:33 -07:00
popaprozac
9fcede47f7 windows improvements 2025-04-22 14:23:32 -07:00
popaprozac
75dbe85ad6 remove comptime check 2025-03-29 23:39:50 -07:00
popaprozac
9a41b0ce9f move icon method, impl interface, check compat, don't panic! 2025-03-29 23:36:25 -07:00
popaprozac
7d0f7f4652 revert linux wait and update payload on win 2025-03-24 21:26:02 -07:00
popaprozac
d25f923721 wait on dbus 2025-03-24 20:07:31 -07:00
popaprozac
1f821667f2 ensure cat id is set for macOS and other rabbit suggestions 2025-03-24 13:56:47 -07:00
popaprozac
7f496c971d fix linux note 2025-03-24 00:16:45 -07:00
popaprozac
9a4542347d follow dbus spec 2025-03-23 23:40:03 -07:00
popaprozac
a68391880c remove deadlock 2025-03-23 00:05:20 -07:00
popaprozac
5ddb27fd3f move chan creation on macos and handle linux shutdown 2025-03-22 23:07:44 -07:00
popaprozac
448c78b226 rewrite and simplify linux impl 2025-03-22 22:36:29 -07:00
popaprozac
ace4f70e3a fix channel cleanup linux 2025-03-22 18:04:30 -07:00
popaprozac
9948cee1f7 monitor dbus connection 2025-03-22 17:51:51 -07:00
popaprozac
f870dcc168 handle notif content errors 2025-03-22 17:39:20 -07:00
popaprozac
b2b8f14053 windows err handling 2025-03-22 16:01:47 -07:00
popaprozac
f6a5bed582 windows err handling 2025-03-22 12:48:47 -07:00
popaprozac
81b40d2afe ensure exactly one delegate created 2025-03-22 12:16:47 -07:00
popaprozac
ef3b7d2bc3 pass service options 2025-03-22 11:51:02 -07:00
popaprozac
be1da68dbc avoid deadlock on win 2025-03-20 22:12:21 -07:00
popaprozac
5dc7bd97f2 refactor/simplify linux 2025-03-20 16:32:53 -07:00
popaprozac
9adeef2bdf fix linux and remove dup code 2025-03-20 16:21:37 -07:00
popaprozac
e55bf8dffc linux bug fix 2025-03-20 13:56:47 -07:00
popaprozac
94f245f035 bug fix 2025-03-20 13:49:49 -07:00
popaprozac
88f13369b6 reorg platform impl 2025-03-20 13:47:03 -07:00
popaprozac
b1db2bba12 add missing error 2025-03-20 10:59:12 -07:00
popaprozac
c58709c1a3 lock registry access/writes 2025-03-19 22:14:17 -07:00
popaprozac
bd857385d3 fix err message 2025-03-19 21:51:57 -07:00
popaprozac
25256f747f allow only one notification service per app 2025-03-19 21:40:26 -07:00
popaprozac
4af058bd02 more cleanup 2025-03-19 18:10:59 -07:00
popaprozac
ee885fea44 fix mem crash 2025-03-18 23:13:37 -07:00
popaprozac
b60ef7729e coderabbit impr 2025-03-18 22:46:44 -07:00
popaprozac
e4e24a0f00 clean 2025-03-18 21:18:16 -07:00
popaprozac
2cb0dac648 set default action id on MATE 2025-03-14 19:13:58 -07:00
popaprozac
1fa68949e6 // 2025-03-14 19:03:33 -07:00
popaprozac
1e67e943df rename auth func 2025-03-14 18:58:23 -07:00
popaprozac
833d8ec7dc refactor macos 2025-03-04 20:07:23 -08:00
Zach Botterman
d9af6dec32
ignore bindings notification callback
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-03-02 22:49:31 -08:00
popaprozac
ad749721e9 can you tell i'm not a go programmer? 2025-02-26 19:57:21 -08:00
Zach Botterman
a807c269cc better interop with obj-c 2025-02-26 18:45:46 -08:00
Zach Botterman
3bdb3ddba3 use app icon 2025-02-26 12:30:31 -08:00
Zach
207b162544 Merge branch 'notifications_darwin' of github.com:popaprozac/wails into notifications_darwin 2025-02-25 17:59:31 -08:00
Zach Botterman
e216b3e513 set icon 2025-02-26 09:32:32 -08:00
Zach Botterman
db2cab7b7c grab icon from app for notifications on windows 2025-02-25 18:04:08 -08:00