Skip to content

Commit 9203934

Browse files
authored
Fix re-render conditions in BackgroundReplacementProvider and logging (#985)
1 parent 1af4d38 commit 9203934

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Changed
1717

1818
- Change to use loggers from `LoggerProvider` as default when initialize background blur/replacement processor.
19+
- Change to not log the entire stringified `options` object in background blur/replacement processor.
1920

2021
### Fixed
2122

23+
- Fix conditions where `BackgroundReplacementProvider` needs to be re-rendered.
24+
2225
## [3.9.0] - 2024-04-12
2326

2427
### Added

src/providers/BackgroundBlurProvider/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ export const BackgroundBlurProvider: FC<React.PropsWithChildren<Props>> = ({
110110
logger.info(
111111
`Initializing background blur processor with, spec: ${JSON.stringify(
112112
spec
113-
)}, options: ${JSON.stringify(options)}`
113+
)}, options: { blurStrength: ${
114+
options?.blurStrength
115+
}, filterCPUUtilization: ${
116+
options?.filterCPUUtilization
117+
}, reportingPeriodMillis: ${options?.reportingPeriodMillis} }`
114118
);
115119

116120
try {

src/providers/BackgroundReplacementProvider/index.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ export const BackgroundReplacementProvider: FC<
8282
return true;
8383
}
8484
if (
85-
prev?.imageBlob?.size === next?.imageBlob?.size ||
86-
prev?.filterCPUUtilization === next?.filterCPUUtilization ||
85+
prev?.filterCPUUtilization !== next?.filterCPUUtilization ||
8786
prev?.logger !== next?.logger ||
8887
prev?.reportingPeriodMillis !== next?.reportingPeriodMillis
8988
) {
@@ -111,7 +110,11 @@ export const BackgroundReplacementProvider: FC<
111110
logger.info(
112111
`Initializing background replacement processor with, ${JSON.stringify(
113112
spec
114-
)}, ${JSON.stringify(options)}`
113+
)}, options: { filterCPUUtilization: ${
114+
options?.filterCPUUtilization
115+
}, reportingPeriodMillis: ${
116+
options?.reportingPeriodMillis
117+
}}`
115118
);
116119

117120
try {

tst/providers/BackgroundBlurProvider/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe.only('BackgroundBlurProvider', () => {
6363
expect(loggerInfoMock).toHaveBeenCalledWith(
6464
`Initializing background blur processor with, spec: ${JSON.stringify(
6565
undefined
66-
)}, options: ${JSON.stringify(blurOptions)}`
66+
)}, options: { blurStrength: ${blurOptions.blurStrength}, filterCPUUtilization: ${blurOptions.filterCPUUtilization}, reportingPeriodMillis: ${blurOptions.reportingPeriodMillis} }`
6767
);
6868
expect(loggerInfoMock).toHaveBeenCalledWith(
6969
'Specs or options were changed. Destroying and re-initializing background blur processor.'

0 commit comments

Comments
 (0)