Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Under Android platform, the gltf model that loads local files will have the wrong path. #667

Open
han-tianyu opened this issue Jan 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@han-tianyu
Copy link

[new Uri(uri, ".")] in UriHelper.GetBaseUri(Uri uri) cannot process files in the jar:file:// path, and an error message is displayed.
It is recommended to change GetBaseUri(Uri uri) to
public static Uri GetBaseUri(Uri uri) { return GetParentUri(uri, 1); }
and
public static Uri GetParentUri(Uri uri, int level) { if (uri == null) return null; string[] segments = uri.Segments; string uriString = uri.Scheme + ":"; if (!string.IsNullOrEmpty(uri.Host)) { uriString += "//" + uri.Host; } if (segments.Length >= level) { string parentDirectory = String.Join("", segments, 0, segments.Length - level).Replace("//", "/"); uriString += parentDirectory; } return new Uri(uriString, UriKind.RelativeOrAbsolute); }

@han-tianyu han-tianyu added the bug Something isn't working label Jan 16, 2024
@atteneder
Copy link
Owner

I couldn't confirm that UriHelper.GetBaseUri does not work with jar:file:// style URIs:

// This works:
Assert.AreEqual(new Uri("jar:file:///dir/sub/"), UriHelper.GetBaseUri(new Uri("jar:file:///dir/sub/file.gltf")));

Closing this now. Feel free to provide a failing test (ideally in UriHelperTest.cs) and re-open the issue.

@atteneder
Copy link
Owner

I was able to reproduce the issue. It's the combination of double-schema (jar:file:) and a (escaped) unicode character that causes problems. Since the double-schema is used on Android only, it only surfaced there.

@atteneder atteneder reopened this Sep 6, 2024
@atteneder atteneder self-assigned this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In progress
Development

No branches or pull requests

2 participants