Skip to content

Android: set a bridge material's emission and reflective channels at once - #471

Merged
doranteseduardo merged 2 commits into
developfrom
fix/android-material-emission
Nov 26, 2026
Merged

doranteseduardo merged 2 commits into
developfrom
fix/android-material-emission

Conversation

@PetkoKuzmanov

Copy link
Copy Markdown
Contributor

Summary

On Android, a material's emission colour, emission texture and reflective texture set from ViroReact never reached the nodes that used it.

Cause

  • Material's Java setters (nativeSetColor, nativeSetTexture) are queued for the rendering thread.
  • ViroReact copies its materials onto nodes (nativeCopyMaterial) before that queue runs.
  • So a channel set through those setters is lost on every copy.

Fix

New Material.setImmutableColor and Material.setImmutableTexture, backed by JNI nativeSetImmutableColor and nativeSetImmutableTexture. They set a named channel on the calling thread, with the thread restriction off, the same way the immutable constructor does. Only viro_react uses them.

Notes

  • viro's fix/android-material-emission uses these, and ships AARs built from this commit.
  • The PBR properties (metalness, roughness and their maps) still go through the queued setters and may be lost the same way. That was not checked.

Testing

Pixel 6 Pro, through viro's branch: emission colour, emission texture and a reflective cube map draw on the material, matching iOS.

PetkoKuzmanov and others added 2 commits November 24, 2026 16:51
…once

Material's setters are queued for the rendering thread, and ViroReact copies its
materials onto nodes before that queue runs, so a channel set through them never
reached the copies. setImmutableColor and setImmutableTexture set a named channel
on the calling thread, as the immutable constructor does.
@doranteseduardo
doranteseduardo merged commit 81e3f6d into develop Nov 26, 2026
4 checks passed
@doranteseduardo doranteseduardo mentioned this pull request Nov 26, 2026
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.

3 participants