🐞 Segfault when using asset catalog colors

オープン
#368 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
swift
領域
desktop

調査の方向性

リンクされた EditorThemeReproduction.zip 内の ContentView.swift から始め、アセットカタログの NSColor 値、特に NSColor.editorBackground を使用して起動時の segfault を再現します。失敗する EditorTheme の構築と、動作する usingColorSpace(.sRGB) のケースを比較します。アセットカタログの色で明示的なカラースペース変換なしに EditorTheme を定義でき、再現アプリが segfault なしで起動すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
Description

When creating an EditorTheme from asset catalog colours, a segfault occurs at launch unless the background colour is explicitly cast to sRGB (NSColor.editorBackground.usingColorSpace(.sRGB)!).

To Reproduce
  1. Create a new SwiftUI macOS app
  2. Add CodeEditSourceEditor as a dependency
  3. Add sRGB colors sets to the Asset catalog
  4. Use those colors through NSColor to define an EditorTheme (e.g. NSColor.editorBackground)
  5. Launch the app
  6. Something segfaults
  7. If you set the background to NSColor.editorBackground.usingColorSpace(.sRGB)!, it doesn't
Expected Behavior

It should be possible to use colours from the asset catalog to define the theme colours without additional hijinks.

Version Information

CodeEditSourceEditor: 0.15.2
macOS: 15.7.4
Xcode: 26.3

Additional Context

Minimal reproduction project: EditorThemeReproduction.zip (ContentView.swift contains all the relevant code.)

How I'm creating the theme (the asset catalog is included with the above project):

extension EditorTheme {
    /// Creates an ``EditorTheme`` from colors defined in the asset catalog.
    static func fromAssetCatalog() -> Self {
        EditorTheme(
            text: EditorTheme.Attribute(color: NSColor.editorText),
            insertionPoint: NSColor.editorInsertionPoint,
            invisibles: EditorTheme.Attribute(color: NSColor.editorInvisibles),

            // This segfaults:
            background: NSColor.editorBackground,

            // This does not, despite the asset catalog color sets being defined as sRGB
            // background: NSColor.editorBackground.usingColorSpace(.sRGB)!,

            lineHighlight: NSColor.editorLineHighlight,
            selection: NSColor.editorSelection,
            keywords: EditorTheme.Attribute(
                color: NSColor.editorKeywords,
                bold: true
            ),
            commands: EditorTheme.Attribute(color: NSColor.editorCommands),
            types: EditorTheme.Attribute(color: NSColor.editorTypes),
            attributes: EditorTheme.Attribute(color: NSColor.editorAttributes),
            variables: EditorTheme.Attribute(color: NSColor.editorVariables),
            values: EditorTheme.Attribute(color: NSColor.editorValues),
            numbers: EditorTheme.Attribute(color: NSColor.editorNumbers),
            strings: EditorTheme.Attribute(color: NSColor.editorStrings),
            characters: EditorTheme.Attribute(color: NSColor.editorCharacters),
            comments: EditorTheme.Attribute(color: NSColor.editorComments)
        )
    }
}
Screenshots
Xcode segfault screenshot
主要言語
Swift
スター
720
フォーク
162
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeEditApp/CodeEditSourceEditor のほかの issue

CodeEditApp/CodeEditSourceEditor の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。