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
@atteneder atteneder moved this to In progress in glTFast development Sep 6, 2024
Needle-Mirror-Bot pushed a commit to needle-mirror/com.unity.cloud.gltfast that referenced this issue Nov 6, 2024
## [6.9.0] - 2024-10-30

### Added
- Package coherence tests that make sure package versions match across exported generator string and documentation.

### Changed
- Moved code examples that are referenced by the documentation into a different folder (`DocExamples`).
- Renamed code example assembly/namespace to `GLTFast.Documentation.Examples` for consistency.

### Fixed
- (Test) LoadTests on Android now succeed by using `UnityWebRequest` to retrieve data from the compressed JAR file.
- Loading glTFs from `StreamingAssets` with relative URIs containing Unicode characters on Android. UriHelper.GetBaseUri and UriHelper.GetUriString handle Android `jar:file://` schema URIs with unicode characters correctly (fixes [#667](atteneder/glTFast#667)).
- XML documentation fixes
- Removed unnecessary "type" property from `package.json`.
- Removed warning about obsolete `GraphicsDeviceType.OpenGLES2` in Unity 2023.1 or newer.
- (Export) Missing texture transform if texture on glTFast material was scaled vertically only.
- Improved reliability by adding null checks and imprecision-aware floating-point comparisons in various places.
- Using immutable fields only in hash code calculation for `ImageExport` classes.
- Refactored `GetHashCode` implementations referencing mutable fields to avoid potential unexpected behavior.
  - `TextureComparer.Equals` made `GetHashCode`/`Equals` for `TextureBase` obsolete, so they've been removed.
  - `MeshPrimitiveComparer` is now used for clustering mesh primitives (instead of `GetHashCode`/`Equals` on `MeshPrimitive` and sub-types).
- Set minimum required Unity version to 2020.3.48f1 in the documentation.
- (Export) Avoid potential loss of data by allocating output streams persistently.
- (Test) Render export test inconclusive if the result has not been validated.
- (Test) More explicit error message by throwing innermost exception while preserving the stack trace during async tests.
- (Documentation) Various clarifications, improvements and fixes, based on user feedback.

### Removed
- Outdated and unused code coverage badge.
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