Skip to content

Implement XrContext for ARKit#833

Merged
chrisfromwork merged 7 commits intoBabylonJS:masterfrom
chrisfromwork:iosContext
Jul 20, 2021
Merged

Implement XrContext for ARKit#833
chrisfromwork merged 7 commits intoBabylonJS:masterfrom
chrisfromwork:iosContext

Conversation

@chrisfromwork
Copy link
Copy Markdown
Contributor

This review contains the following changes:

  1. XR resources for ARKit are moved to a shared location (IXrContextARKit) that can be accessed by external plugins through the javascript runtime
  2. Functionality is added so that ARKit anchors created outside the BabylonNative XR system can be declared to the XR system.

Note: these changes are needed for iOS XR service scenarios such as Azure Spatial Anchors support.

Comment thread Dependencies/xr/Source/ARKit/XR.mm Outdated
PUBLIC "include")

target_link_to_dependencies(napi
target_link_libraries(napi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was this change intentional?

Copy link
Copy Markdown
Contributor Author

@chrisfromwork chrisfromwork Jul 20, 2021

Choose a reason for hiding this comment

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

yes depending on cmake version target_link_to_dependencies doesn't exist as a valid cmake command. I'm not sure why we've been using it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

actually looks like this was a custom command. Do we have more context around why we've been using this custom command:

https://github.com/BabylonJS/BabylonNative/blob/master/Dependencies/CMakeExtensions/CMakeLists.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this was originally introduced, among other reasons, to copy DLLs for V8 on Windows. Does that still work with this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I may be naive/wrong here, but it doesn't look like we are setting ON_LINKED_AS_DEPENDENCY_CMAKE_FILES for this library, so I don't think using the custom target_link_to_dependencies is necessary here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if folks want this reverted, I can look into updating our consuming projects to locate this target_link_to_dependencies function. That going said, if it doesn't serve any additional purpose it seems worth converting back to target_link_libraries so that external consumers of napi jsi don't have to include these additional cmake function definitions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

given this could potentially have issues on UWP but I've been primarily testing on iOS, I'm just going to refer this change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will be using add_on_linked_as_dependency_cmake_file for napi-jsi in order to pull in v8jsi dll's (see #832). I also thought CMakeLists globally enforced a minimum version across files, so I'm not sure why iOS specifically would have issues consuming the custom function, unless there's a file with a version setter that needs to get revved.

PUBLIC "include")

target_link_to_dependencies(napi
target_link_libraries(napi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this was originally introduced, among other reasons, to copy DLLs for V8 on Windows. Does that still work with this change?

Comment thread Dependencies/xr/Source/ARKit/XR.mm Outdated

struct System::Impl {
public:
std::shared_ptr<XrContextARKit> XrContext{std::make_shared<XrContextARKit>()};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this ownership actually conceptually shared? If not, could this be a simpler type?

Copy link
Copy Markdown
Contributor Author

@chrisfromwork chrisfromwork Jul 20, 2021

Choose a reason for hiding this comment

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

I don't think it will be possible to hand a shared pointer across dll/lib boundaries. That going said, from a legibility standpoint id prefer this to stay a pointer compared to a memory reference to a struct field. We could change this to a unique_ptr if that's preferred over shared_ptr?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

talked offline, opted to switch to unique_ptr. this should now be fixed.

@chrisfromwork chrisfromwork enabled auto-merge (squash) July 20, 2021 19:17
@chrisfromwork chrisfromwork merged commit 4de24f7 into BabylonJS:master Jul 20, 2021
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.

4 participants