Skip to content

Refactor JCA to extract OpenGL/EGL effects into dedicated :core📷effects module#527

Open
davidjiagoogle wants to merge 21 commits into
mainfrom
david/splitEffects
Open

Refactor JCA to extract OpenGL/EGL effects into dedicated :core📷effects module#527
davidjiagoogle wants to merge 21 commits into
mainfrom
david/splitEffects

Conversation

@davidjiagoogle

@davidjiagoogle davidjiagoogle commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This PR modularizes the OpenGL/EGL surface-processing and single-stream effects in the Jetpack Camera App (JCA), separating them into a dedicated :core:camera:effects module.

Key Changes:

  1. New Interface: Defined SingleStreamEffectProvider in :core:camera as the injection contract.
  2. Modularized Effects: Moved the effects/ package hierarchy (including SingleSurfaceForcingEffect, CopyingSurfaceProcessor, shaders, and GL helper classes) from :core:camera to :core:camera:effects.
  3. Decoupled Dependencies: Transferred libs.androidx.graphics.core (OpenGL/EGL wrapper library) to :core:camera:effects's build.gradle.kts.
  4. Hilt Injection: Registered SingleStreamEffectProviderImpl using Hilt @IntoSet multi-binding. CameraXCameraSystem now injects Set<SingleStreamEffectProvider> and passes the effect provider to CameraSession dynamically.
  5. Configurable Exclusion: By separating effects into a new module, we enable build configurations (like "lite" builds) to completely exclude the :core:camera:effects dependency, preventing the androidx.graphics:graphics-core library (~15KB) from being compiled and bundled into the production APK.

Tried out removing effects module in the app layer in the david/splitEffectsTryout branch

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request modularizes the camera effects by introducing a new :core:camera:effects module and decoupling SingleSurfaceForcingEffect from the core camera session. It defines a SingleStreamEffectProvider interface and injects its implementation using Hilt multibindings. The review feedback highlights a potential compilation error if the effects module is excluded, which can be resolved using @Multibinds. Additionally, suggestions were made to adhere to the repository style guide by restricting visibility to internal, adding KDoc documentation, and adjusting the Hilt component scope.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread data/camera/src/main/java/com/google/jetpackcamera/data/camera/CameraModule.kt Outdated
@davidjiagoogle davidjiagoogle requested a review from temcguir June 3, 2026 23:48
davidjiagoogle and others added 3 commits June 5, 2026 19:05
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

@temcguir temcguir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The overall direction of moving effects into a dedicated module and injecting them to allow for "lite" builds is solid. However, there are a few architectural issues with the current implementation that prevent it from being truly extensible for arbitrary custom effects.

Most notably, the PR description states that this uses Hilt @IntoSet multi-binding, but the code actually relies on @BindsOptionalOf to inject a single Optional<SingleStreamEffectProvider>. This single-instance injection prevents multiple effects from coexisting and forces developers to completely overwrite the module if they want to inject their own custom effect.

To resolve this, I've left a few inline comments outlining an approach that aligns with our existing LowLightBoost and ImagePostProcessor implementations:

  1. Generalize the interface: Rename SingleStreamEffectProvider to a generic CameraEffectProvider.
  2. Use a Map Registry: Replace CameraSessionOptionalModule with a @Multibinds module inside :data:camera to provide a Map<CameraEffectFeatureKey, Provider<CameraEffectProvider>>. This guarantees the Map is always present (even if empty in lite builds) and completely eliminates the need for Optional injection.
  3. Drive via Settings: Treat the active effect as a configurable UI state by adding it to CameraAppSettings (and SessionSettings), rather than hardcoding it in startCamera. CameraSession can then simply use the setting state to look up the correct provider from the injected Map registry.

@davidjiagoogle davidjiagoogle requested a review from temcguir June 15, 2026 21:52
Comment thread settings.gradle.kts Outdated
# Conflicts:
#	core/camera/src/main/java/com/google/jetpackcamera/core/camera/effects/CameraEffectFeatureKey.kt
#	core/model/src/main/java/com/google/jetpackcamera/model/CameraEffect.kt
#	core/model/src/main/proto/com/google/jetpackcamera/model/proto/stream_config.proto
#	data/settings/src/main/java/com/google/jetpackcamera/settings/JcaSettingsSerializer.kt
#	data/settings/src/main/java/com/google/jetpackcamera/settings/LocalSettingsRepository.kt
#	data/settings/src/main/java/com/google/jetpackcamera/settings/SettingsRepositoryModule.kt
#	data/settings/src/main/proto/com/google/jetpackcamera/settings/jca_settings.proto
#	data/settings/testing/src/main/java/com/google/jetpackcamera/settings/testing/FakeJcaSettingsSerializer.kt
#	data/settings/testing/src/main/java/com/google/jetpackcamera/settings/testing/FakeSettingsRepository.kt
…, add dynamic effect targets and capabilities map, and remove hardcoded string checks in settings
@davidjiagoogle davidjiagoogle requested a review from temcguir June 29, 2026 18:03
Comment thread build.log Outdated
@davidjiagoogle davidjiagoogle requested a review from temcguir June 30, 2026 21:42
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