LearnNewsExamplesServices
Frontmatter
id7827
titleInitialize Neo.apps in App worker and optimize window-specific events
stateClosed
labels
enhancementai
assigneestobiu
createdAtNov 20, 2025, 9:28 PM
updatedAtNov 20, 2025, 9:36 PM
githubUrlhttps://github.com/neomjs/neo/issues/7827
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 20, 2025, 9:36 PM

Initialize Neo.apps in App worker and optimize window-specific events

Closed v11.8.0 enhancementai
tobiu
tobiu commented on Nov 20, 2025, 9:28 PM

Problem

  1. Neo.apps and Neo.appsByName are lazily initialized in Neo.controller.Application#construct. Accessing them in Neo.worker.App (e.g., createNeoInstance) before any app is created can cause a crash if they are undefined.
  2. onVisibilityChange and onOrientationChange currently iterate over all apps to find the matching instance or broadcast the event. Since these events are tied to a specific window, we can use a direct lookup for better performance and correctness.

Proposed Changes

  1. Initialize Global Maps: In src/worker/App.mjs construct(), initialize Neo.apps and Neo.appsByName to {}.
  2. Optimize onVisibilityChange: Replace the Object.values(Neo.apps) iteration with a direct lookup: Neo.apps[msg.data.windowId].
  3. Optimize onOrientationChange: Replace the Object.values(Neo.apps) iteration with a direct lookup using the windowId from the event data.

Note on createNeoInstance: The fallback logic let appName = Object.values(Neo.apps)[0]?.name is preserved but becomes safe due to the initialization in step 1.

tobiu added the enhancement label on Nov 20, 2025, 9:28 PM
tobiu added the ai label on Nov 20, 2025, 9:28 PM
tobiu assigned to @tobiu on Nov 20, 2025, 9:29 PM
tobiu referenced in commit d6cb7fa - "Initialize Neo.apps in App worker and optimize window-specific events #7827" on Nov 20, 2025, 9:36 PM
tobiu closed this issue on Nov 20, 2025, 9:36 PM