fix(macos): playback, crossfade decipher, packaging, adblocker, dev icon#4390
Open
perlytiara wants to merge 3 commits into
Open
fix(macos): playback, crossfade decipher, packaging, adblocker, dev icon#4390perlytiara wants to merge 3 commits into
perlytiara wants to merge 3 commits into
Conversation
added 3 commits
March 28, 2026 08:32
- Resume Web Audio (renderer + main IPC) and disable background throttling to reduce silent playback on macOS ARM after suspend/background. - Bump youtubei.js to 17.x and align downloader Platform.shim.eval with v17 script output (fixes crossfade audio-url TypeError: nFunction is not a function). - Call removeContentSecurityPolicy before initHook/loadAllMainPlugins so session webRequest wrapping stays compatible with adblocker blocking. - Add adblocker plugin (Ghostery) with cached engine under userData. - Resolve BrowserWindow icon to an absolute path so dev/preview shows the app icon, not the default Electron icon. - Wrap setLoginItemSettings in try/catch for dev environments where login items are not permitted. - macOS packaging: committed icon.icns and electron-builder target path for arm64 DMG builds without Xcode 26 actool issues. - Misc strict TS fixes (websocket cast, auth-proxy Buffer, skip-silences analyzer). Tested on: macOS (darwin 25.3.0), Apple Silicon (ARM64), pnpm dist:mac:arm64. Made-with: Cursor
…owlist - Install pear-dynamic-script policy and proxy Function so new Function(string) works under YT Music Trusted Types (stops console blocks / broken dynamic code). - Resume AudioContext on timeupdate while playing and on pageshow after bfcache to reduce silent-audio with video still advancing. - Adblocker: merge @@ allow rules for first-party music.youtube.com youtubei/stats/ptracking/generate_204 and play.google.com log (and pagead on YTM) so ERR_BLOCKED_BY_CLIENT does not hit player-critical calls. - Crossfade: try/catch getStreamURL; restore video volume if URL missing so we do not stay muted after a failed transition. Verified: pnpm typecheck, pnpm build, pnpm dist:mac:arm64 (Apple Silicon). Made-with: Cursor
Remove merged @@ rules (pagead, broad youtubei, etc.). Ghostery prebuilt ads+tracking only, plus optional additionalBlockLists. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR bundles fixes and improvements developed and verified on Apple Silicon (macOS, darwin 25.3.0): silent playback after Web Audio suspend, crossfade/downloader crashes after a
youtubei.jsplayer update, Ghostery-based ad/tracking blocking (no broad first-party allowlists that bypass ads), Trusted Types compatibility in the renderer, correct window icon in dev, and arm64 DMG packaging.Environment (author)
pnpm typecheck,pnpm build,pnpm dist:mac:arm64— DMG:pack/YouTube Music-3.11.0-arm64.dmg(not committed; local artifact only)Changes
Playback (macOS / Web Audio)
AudioContexton visibility, focus, play, user input, and IPCpeard:resume-audio-context.timeupdatewhile the video is playing, retryresume()if the context is stillsuspended(avoids “silent audio, picture still moving”). Alsopageshowwhen returning from bfcache.focus/show; setbackgroundThrottling: falseon the BrowserWindow so timers/media scheduling stay steadier in the background.Trusted Types (YouTube Music)
src/trusted-types-function-shim.ts, imported first fromrenderer.ts: registers a small Trusted Types policy and proxiesFunction/new Functionso the function body is passed throughcreateScript, satisfying Chromium when YT Music enforces Trusted Types (fixes console errors like “TrustedScript assignment” / Function constructor blocked).Crossfade /
audio-url(exportedVars.nFunction is not a function)Platform.shim.eval: execute the script YouTube.js emits vianew Function(data.output)(), matching v17 output (no separatenFunctionwiring).getStreamURLin try/catch; if there is no URL, restore<video>volume when it was left at0after a failed transition.Adblocker + session hooks
src/plugins/adblocker/: Ghostery@ghostery/adblocker-electron, engine cache atuserData/adblocker-engine.bin.removeContentSecurityPolicy()runs beforeinitHook/loadAllMainPluginssowebRequestwrapping stays compatible with blocking (per comment inindex.ts).@@allowlist formusic.youtube.com/pagead/ broadyoutubei: earlier attempts whitelisted ad and ad-adjacent endpoints (e.g.www.youtube.com/pagead, all ofyoutubei), which allowed ads again. The engine stays prebuilt ads + tracking only, plus optionaladditionalBlockListsin plugin settings for power users.Dev experience
BrowserWindowiconto an absolute path (tryapp.getAppPath(),cwd, then repo-relative from bundled main) so electron-vite preview shows the real app icon instead of the default Electron icon.setLoginItemSettingsintry/catch; in dev, log a short warning when the OS denies login-item changes.macOS packaging
assets/generated/icons/mac/icon.icnsand point electron-builder at it so arm64 DMG builds work without relying on Xcode 26actool.iconissues.Misc
Buffer, skip-silences analyzer callback.Notes
dist:mac:arm64was built with signing identity unset (expected for local builds); release pipelines should still use your usual signing/notarization setup.pack/; it is not part of the git diff.perlytiara/pear-desktop→pear-devs/pear-desktop(no direct push permission on upstream).Prepared with assistance from Cursor.