Skip to content

fix(ios): guard against nil iconImage in marker setImage callback#184

Merged
mym0404 merged 2 commits intomym0404:mainfrom
spencer0124:fix/nil-marker-icon-crash
Apr 6, 2026
Merged

fix(ios): guard against nil iconImage in marker setImage callback#184
mym0404 merged 2 commits intomym0404:mainfrom
spencer0124:fix/nil-marker-icon-crash

Conversation

@spencer0124
Copy link
Copy Markdown
Contributor

Summary

  • Add nil check before setting NMFMarker.iconImage in the getImage callback to prevent crash when image is nil

Problem

NMFMarker crashes with SIGABRT when iconImage is set to nil. This occurs when nmap::getImage returns nil via callback (e.g., image load failure, unsupported symbol name).

Crash stack:

-[NMFMarker setIconImage:] (NMFMarker)
-[RNCNaverMapMarker setImage:]::block (RNCNaverMapMarker.mm:103)

Root Cause

ImageUtil.h's getImage can call callback(nil) in two places (line 80, line 112), but RNCNaverMapMarker.mm:103 sets self.inner.iconImage = image without nil check.

Fix

One-line nil guard before setting iconImage.

Fixes #183

🤖 Generated with Claude Code

NMFMarker crashes with SIGABRT when iconImage is set to nil.
This happens when getImage callback returns nil (e.g. image load failure).

Add nil check before setting iconImage to prevent crash.

Fixes mym0404#183
@mym0404
Copy link
Copy Markdown
Owner

mym0404 commented Apr 5, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c606352e1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +102 to +104
if (image) {
self.inner.alpha = 1;
self.inner.iconImage = image;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore marker alpha when callback image is nil

setImage hides the marker with _inner.alpha = 0 before requesting the image, but this change now restores alpha only inside if (image). Because nmap::getImage can legally call back with nil (e.g., unsupported symbol or failed image resolution), the marker remains permanently transparent after the callback, so users see missing markers instead of a fallback/default icon. Keep alpha restoration outside the nil guard (and optionally preserve/set a fallback icon) to avoid this regression.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify code as you suggested.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mym0404
Copy link
Copy Markdown
Owner

mym0404 commented Apr 5, 2026

@codex accept above suggestion/

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex couldn't complete this request. Try again later.

… markers

Move `self.inner.alpha = 1` outside the `if (image)` block so that
markers always become visible again after the getImage callback,
even when the image is nil. Previously, a nil callback left the marker
permanently transparent (alpha = 0) since alpha restoration was
only inside the nil guard.

Addresses review feedback from @chatgpt-codex-connector.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mym0404
Copy link
Copy Markdown
Owner

mym0404 commented Apr 6, 2026

@spencer0124 Thank you for your edit. I'll merge this PR soon.

@mym0404 mym0404 merged commit 56f620f into mym0404:main Apr 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Crash when NMFMarker.iconImage is set to nil from getImage callback

2 participants