Crash in Sheet.GetTexture(): Nullable<Rectangle>.Value thrown when glyphs are rasterised off the render thread
メンテナーはふだん 9 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 22/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
The race sits between Sheet.GetTexture() and Sheet.CommitBufferedData() in OpenRA.Game/Graphics/Sheet.cs, which read and write dirtyRegion. The off-thread writer is MissionBrowserLogic.SelectMap triggering glyph rasterisation through the shared font SheetBuilder created in Renderer.InitializeFonts(). Done means the campaign briefing list no longer throws when a non-ASCII font is used, and the fix is agreed on, since the issue weighs a minimal read-once change against serialising sheet access or moving the work to Game.RunAfterTick.
索引モデルが issue の本文から書いたものです。
説明
Engine: playtest-20261026 (x64, .NET 10.0.13), Windows 11 26220
Mod: ra, all Fonts: in mods/ra/mod.yaml pointed at Noto Sans SC, campaign briefings translated to Simplified Chinese
The crash is engine-side, but it needs a font whose glyphs are not all pre-cached to reproduce.
Stack trace
Exception of type `System.InvalidOperationException`: Nullable object must have a value.
at System.Nullable`1.get_Value()
at OpenRA.Graphics.Sheet.GetTexture()
at OpenRA.Graphics.SpriteRenderer.Flush()
at OpenRA.Renderer.EnableScissor(Rectangle rect)
at OpenRA.Mods.Common.Widgets.ScrollPanelWidget.DrawOuter()
at OpenRA.Widgets.Widget.DrawOuter()
at OpenRA.Widgets.Ui.Draw()
at OpenRA.Game.RenderTick()
at OpenRA.Game.Loop()
at OpenRA.Game.Run()
Reproduction
- Use a font with non-ASCII glyphs for all
Fonts:entries (e.g. Noto Sans SC inmods/common/) and translate a few campaign briefings. - Red Alert → Campaign → click missions in the list.
- Crash within seconds (reproduced twice in 3 minutes).
With the stock FreeSans.ttf the same screen never crashes: SpriteFont's constructor pre-caches 0x20..0x7E, so the campaign briefing needs no new glyphs.
Cause
Sheet.dirtyRegion (Rectangle?) is read and written from two threads without any synchronisation:
// OpenRA.Game/Graphics/Sheet.cs (playtest-20261026)
if (dirtyRegion != null && texture.Size == Size && Size != dirtyRegion?.Size)
{
var region = dirtyRegion.Value; // another thread cleared the nullable in between
- Render thread:
SpriteRenderer.Flush()→Sheet.GetTexture(). - Background thread:
MissionBrowserLogic.SelectMap()startsnew Thread(...)that callsWidgetUtils.WrapText(...)anddescriptionFont.Measure(...). Glyph rasterisation is lazy and writes into the shared fontSheetBuilder(Renderer.InitializeFonts()creates a single builder for every font), which callsSheet.CommitBufferedData()and, when a sheet fills up,ReleaseBufferAndTryTransferTo()→Sheet.GetTexture()off the render thread.
Those two methods are the only places that assign dirtyRegion = null, so one thread can clear it while the other is between the != null check and .Value.
Confirmed in the shipped assembly: Sheet.GetTexture() calls Nullable<Rectangle>::get_Value at IL body offset 0x00BA, and Sheet.CommitBufferedData() at 0x0035.
Two changes in this playtest made the race easy to hit:
Sheet.dirtyRegion(partial upload) is new.playtest-20260222'sSheet.csuploads the whole sheet withSetDataand has no nullable, so this is a regression.ThreadedGraphicsContextmakestexture.Sizea blocking cross-thread round trip, widening the race window from nanoseconds to hundreds of microseconds.
Suggested fix
Minimum: read the field once.
var region = dirtyRegion;
if (region != null && texture.Size == Size && Size != region.Value.Size)
{
texture.SetSubData(data, region.Value.X, region.Value.Y, region.Value.Width, region.Value.Height);
I verified locally that replacing both get_Value() calls with GetValueOrDefault() (identical signature, 2 bytes of IL) stops the crash; the glyph sheet then occasionally re-uploads a stale region, which is harmless.
Better: serialise Sheet access (lock or marshal commits to the render thread), and/or move the WrapText/Measure work in MissionBrowserLogic.SelectMap into Game.RunAfterTick so glyphs are only rasterised on the render thread.
Localisation contribution
I maintain a Simplified Chinese localisation for playtest-20261026 covering Red Alert, Tiberian Dawn and Dune 2000 (208 translated files, including 140 campaign briefings), released under GPL-3.0. The patch and full file manifest are available at Janlhin/OpenRA_Simplified_Chinese. I would be glad to contribute the translations upstream in whatever form the team prefers — per-mod Fluent .ftl pull requests, or a small first batch to validate the workflow — and to help with review and a shared glossary. Happy to split it into reviewable chunks and follow CONTRIBUTING.
- 主要言語
- C#
- スター
- 17.9k
- フォーク
- 3.1k
- 平均マージ
- 9日 2時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenRA/OpenRA のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 9 日以内に返信
-
Captured Harkonnen Heavy Factories do not unlock Devastators in Atreides missions 7–9対応中かも @Porenutak が 27 日前に担当しました。 オープンBug Dune 2000
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenRA/OpenRA#22679 · コメント 5 件 ·
メンテナーはふだん 9 日以内に返信
-
Map.Save() throws InvalidOperationException when StagedMapFiles contains more than one file対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
OpenRA/OpenRA#22651 · コメント 1 件 ·
メンテナーはふだん 9 日以内に返信
-
Add lighting (and maybe weather) effects to `top-o-the-world`対応中かも @Leo512bit が 142 日前に担当しました。 オープンIdea/Wishlist Red Alert
難易度 2/5 1〜2日 初心者へのやさしさ 68/100
OpenRA/OpenRA#22217 · コメント 1 件 ·
メンテナーはふだん 9 日以内に返信
-
Polish
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OpenRA/OpenRA#18553 · コメント 1 件 ·
メンテナーはふだん 9 日以内に返信
似ている issue
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
juandresrodca/AdminForge#70 ·
メンテナーはふだん 1 日以内に返信
-
bug localization small
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Issue: Bug Low Priority Parity
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
chris4aker/OfflineDAoC-LivingServer#985 ·
メンテナーはふだん 1 日以内に返信
-
Markdown.Normalize drops fence delimiters on unclosed fenced code blocks対応中かも @nphungthinh2601 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信