Fix race that dropped every successful cloud anchor upload callback - #37
Open
Brian-Simmons1 wants to merge 1 commit into
Open
Fix race that dropped every successful cloud anchor upload callback#37Brian-Simmons1 wants to merge 1 commit into
Brian-Simmons1 wants to merge 1 commit into
Conversation
uploadAnchor added the anchor to pendingAnchors only after awaiting the platform call, but the native side invokes onCloudAnchorUploaded before resolving that call. The success handler therefore always hit an empty pendingAnchors list and threw "Bad state: No element": the anchor was hosted to the cloud, but onAnchorUploaded never fired and the caller never learned the cloud anchor ID. Register the anchor as pending before the call, and unregister it on failure. Found and fixed in production while building VEEOP (https://veeop.com), an AR social location platform - https://github.com/VEEOP-app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ARAnchorManager.uploadAnchoradds the anchor topendingAnchorsonly after awaiting the platform call:But the native side invokes
onCloudAnchorUploadedbefore resolving that method call (the Kotlin handler fires the callback and then callsresult.success). So when the success callback runs,pendingAnchors.where((e) => e.name == name).firstalways throwsBad state: No element— the anchor hosts successfully in the cloud (log showsUPLOADED ANCHOR WITH ID: ua-…), butonAnchorUploadednever fires and the caller never receives the cloud anchor ID.This PR registers the anchor as pending before the platform call and removes it again on failure, so the callback finds it and the API works as documented.
Verified on device: before — every successful host logged
Error caught: Bad state: No element; after —onAnchorUploadedfires with the populatedcloudanchorid.Found and fixed in production while building VEEOP, an AR social location platform (github.com/VEEOP-app).