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

fix(native): use FS for Android Release Mode #2980

Closed
wants to merge 2 commits into from

Conversation

XantreDev
Copy link

#2644
This bug reproduced in my case and I patched fiber with solution from comment and its resolved. I want it to work in react native out of the box

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 052f5bf:

Sandbox Source
example Configuration

@CodyJasonBennett CodyJasonBennett changed the title React-native texture fix fix(native): use FS for Android Release Mode Aug 30, 2023
@@ -16,6 +16,7 @@ export type { ThreeEvent, Events, EventManager, ComputeFunction } from './core/e
export { createEvents } from './core/events'
export type { ObjectMap, Camera } from './core/utils'
export * from './native/Canvas'
export * from './native/polyfills'
Copy link
Member

Choose a reason for hiding this comment

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

Are you using this for testing? We don't want an asymmetrical export between web and native since that can create broken behavior in isomorphic apps.

Copy link
Author

@XantreDev XantreDev Aug 30, 2023

Choose a reason for hiding this comment

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

No. Monkeypathing on useLayoutEffect is not really correct, because if we are using some loader with preload on top level - it throws. For example this code will thrown, because it's called before monkeypathing.

useGLTF.preload(require('sdfsdf.glb))

Maybe the good way to provide polyfills is to use polyfills on top level

Copy link
Member

Choose a reason for hiding this comment

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

For sure. We'll have to polyfill at the native entrypoint.

@XantreDev
Copy link
Author

It affects models too (glb in my case), but I don't know how to solve it in case of monkeypatching, i just modified workaround #2577 (comment).

@CodyJasonBennett
Copy link
Member

For background, looks like the root issue is in -- https://github.com/expo/expo/blob/1277abdd1ecb21aa43b22a48282439c97b1c1798/packages/expo-asset/src/Asset.ts#L166 which is later used https://github.com/expo/expo/blob/1277abdd1ecb21aa43b22a48282439c97b1c1798/packages/expo-asset/src/PlatformUtils.ts#L59C43-L59C43, reflecting the patches here. There is special casing for drawables on Android that is independent of the bundler.

Performing the patch after acquiring the asset should give Asset#downloadAsync correct behavior. I'll test this further to ensure this covers the GLB case, but this means upstreaming fixes is later possible.

@CodyJasonBennett
Copy link
Member

CodyJasonBennett commented Sep 1, 2023

I've been making related fixes for GLB and internal image handling in #2982. Can you try with the following to see if it handles your case? Polyfills are added at the top-level and it has a direct fix for Android Release Mode.

// package.json
{
  "dependencies": {
    "@react-three/fiber": "https://pkg.csb.dev/pmndrs/react-three-fiber/commit/0772cfaa/@react-three/fiber"
  }
}

@CodyJasonBennett
Copy link
Member

Continuing in #2982.

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