Skip to content

Return nodeName instead of anchorName on Android (replicates upstream #13) - #1

Merged
iamEtornam merged 1 commit into
mainfrom
upstream-pr-13-android-nodename
Jul 8, 2026
Merged

Return nodeName instead of anchorName on Android (replicates upstream #13)#1
iamEtornam merged 1 commit into
mainfrom
upstream-pr-13-android-nodename

Conversation

@iamEtornam

Copy link
Copy Markdown
Owner

Replicates upstream PR hlefe#13 by @Mako-L.

Change: In ArView.kt, onNodeTap now returns the tapped node's own name (node.name) instead of the resolved anchor name, matching the iOS behaviour.

Original author: Mako-L. Upstream PR: hlefe#13

Return nodeName instead of anchorName  on android like is done on iOS.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the node tap handler in ArView.kt to pass the tapped node's name directly instead of traversing the hierarchy to find the anchor name. The review feedback correctly identifies that this change leaves the parent-traversal loop and associated variables as dead code, which should be removed. Additionally, a null-safety check is recommended for the nullable nodeName before invoking the platform channel to avoid passing null values to Dart.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

if (node != null) {
var anchorName: String? = null
var currentNode: Node? = node
val nodeName = node.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since nodeName is now used instead of anchorName for the tap event, the anchorName and currentNode variables, as well as the entire while loop traversing the parent hierarchy, are now dead code. They should be removed to clean up the codebase and avoid unnecessary parent-traversal and map-lookup operations on every tap.

}
if(handleTaps) {
objectChannel.invokeMethod("onNodeTap", listOf(anchorName))
objectChannel.invokeMethod("onNodeTap", listOf(nodeName))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since node.name is nullable, nodeName can be null. Passing a list containing null to the Flutter channel will result in tappedNode.toString() being called on null in Dart, which produces the string "null". To prevent this, we should only invoke the method if nodeName is not null.

Suggested change
objectChannel.invokeMethod("onNodeTap", listOf(nodeName))
nodeName?.let { objectChannel.invokeMethod("onNodeTap", listOf(it)) }

@iamEtornam

Copy link
Copy Markdown
Owner Author

Review — VERDICT: ✅ LGTM (with nits)

Replicates upstream hlefe#13. Kotlin-only; not compilable by flutter analyze here — reviewed by static read.

  • Correct & matches iOS. onNodeTap now returns node.name (the Flutter-supplied node id, set at ArView.kt:289) instead of the resolved anchor name. iOS returns the node name too (IosARView.swift:552), so this aligns the platforms. The old anchorName was a genuinely different value.
  • Dart side safe. ar_object_manager.dart:54 casts to List<dynamic> and maps .toString(), so no cast break.
  • 🔸 Nit: the anchorName resolution loop (ArView.kt:501-512) is now dead code computed and discarded on every tap — worth deleting.
  • ⚠️ Edge case (unverified): iOS walks up to the ancestor whose name starts with [#; this change reads node.name off the raw tapped node with no upward traversal. If SceneView hands back a composed sub-mesh, the name could differ. Low risk in practice.

Safe to merge.

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.

2 participants