Skip to content

Remove duplicate environment creation - #651

Merged
cdata merged 3 commits into
masterfrom
double_env
Jun 21, 2019
Merged

cdata merged 3 commits into
masterfrom
double_env

Conversation

@elalish

@elalish elalish commented Jun 19, 2019

Copy link
Copy Markdown
Contributor

Fixes #649

Our environments were getting loaded twice, once in firstUpdate, and again in update. I think generation only happened once because of three's caching, but reading in the HDR file and running PMREM were both definitely happening twice, and are both quite expensive. I can't see anything going wrong from removing the firstUpdate function, but I'm also not sure why it was there, so please let me know if I've missed some side effect.

@elalish
elalish requested review from cdata and jsantell June 19, 2019 16:25
@elalish elalish self-assigned this Jun 19, 2019
@cdata

cdata commented Jun 19, 2019

Copy link
Copy Markdown
Contributor

👍 How can we catch regressions?

@elalish

elalish commented Jun 19, 2019

Copy link
Copy Markdown
Contributor Author

I'm not sure; I'm hoping our current tests and fidelity tests will tell us. Can you think of new cases we should add?

@cdata

cdata commented Jun 19, 2019 •

Copy link
Copy Markdown
Contributor

Our current test suite is not comprehensive, and we rely on folks layering on regression tests and feature tests as changes are made.

Off the top of my head, I see tests here for checking the background color when nothing is configured, but not the environment lighting:

https://github.com/GoogleWebComponents/model-viewer/blob/42553986abe851fbe966b838bad5c5eafc9704c6/src/test/features/environment-spec.ts#L148-L160

Since the comment that you removed claims that firstUpdated was needed in the case that no environment is configured, it sounds like this is an important test case to cover.

Separately, we are fixing a problem where the environment is updated too many times. We can probably author a test that measures the number of times the environment is updated for a given configuration and assert that it is the expected number.

@elalish

elalish commented Jun 19, 2019

Copy link
Copy Markdown
Contributor Author

Good idea, I've added the unconfigured tests. As for checking how many times the environment is generated, I would spend significantly more time making that test than on the whole PR and I still wouldn't be convinced it would reliably catch those perf bugs. I think this is a relatively unlikely regression, so I would skip this particular test, but you're welcome to overrule me if this is more important than our other work.

@cdata

cdata commented Jun 20, 2019

Copy link
Copy Markdown
Contributor

I would spend significantly more time making that test than on the whole PR

This is the reason why easy / small PRs are dangerous :)

@cdata

cdata commented Jun 20, 2019

Copy link
Copy Markdown
Contributor

I think for the near term let's just add a test that waits for a reasonable window of time (call it one second) after the model loads and asserts that the environment did not re-generate in that window of time.

In some failure scenarios, this test will fail flakily. But, I think flakey failure in this case is better than no test at all.

@cdata
cdata merged commit b27c65f into master Jun 21, 2019
@cdata
cdata deleted the double_env branch June 21, 2019 17:01
@cdata cdata added this to the v0.6.0 milestone Aug 26, 2019
elalish added a commit to elalish/model-viewer that referenced this pull request Feb 4, 2020
* removed firstUpdate

* added tests

* added duplicate environment test
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.

PMREM appears to be applied to environment maps twice

2 participants