Comments (8)
Awesome, that fixed the iframe flickering, thanks!
For other cases, maybe you can hide the handle
, delayRender
, and continueRender
details inside one hook:
function useResumer() {
const [handle] = useState(() => delayRender());
const resumeRender = useCallback(() => {
continueRender(handle);
}, [handle]);
return resumeRender;
}
or something like that.
from remotion.
Maybe iframe
s have a similar problem? They consistently disappear in some frames. Here's an example.
from remotion.
Good point! Let's also make an IFrame component then.
Can you try if this <IFrame> component solves your problem?
import {useCallback, useState} from 'react';
import {continueRender, delayRender} from 'remotion';
export const IFrame: React.FC<Omit<
React.DetailedHTMLProps<
React.IframeHTMLAttributes<HTMLIFrameElement>,
HTMLIFrameElement
>,
'onLoad'
>> = (props) => {
const [handle] = useState(() => delayRender());
const onLoad = useCallback(() => {
continueRender(handle);
}, [handle]);
return <iframe {...props} onLoad={onLoad} />;
};
I'll then add it to Remotion Core, add documentation and improve DX by adding an ESLint Rule to the Remotion plugin!
from remotion.
Hey @JonnyBurger awesome project!
I think that suspense can help with this issue!
We can create custom suspense
catcher and delayRender
inside, like this
import {continueRender, delayRender} from 'remotion';
class VideoSuspense extends Component {
constructor () {
this.state = {
loading: false
}
}
componentDidCatch(promise) {
if (isPromise(promise)) {
this.setState({ loading: true })
delayRender()
promise.then(() => {
this.setState({ loading: true })
continueRender()
})
} else {
throw promise
}
}
render () {
return this.state.loading ? null : this.props.children
}
}
// root
<VideoSuspense>
<Video/>
</VideoSuspense>
it should be better, because we don't need to wrap components that already support suspense with remotion delayRender/continueRender
, and can use existed ones
what do you think about that? I can help with implementation
from remotion.
@jeetiss If that is possible using Suspense, then that's definitely preferrable!
But how does it work? Where does that promise come from? How do we hook into the onLoad
function of img, iframe component?
from remotion.
Since a lot of people are affected, I am going ahead with the original plan and will merge #32. There is now also an ESLint rule enabled which will warn you if you use the native or <iframe> component!
from remotion.
Fixed by #32
from remotion.
@JonnyBurger, yes ofc! i am going to open new issue for suspense
But how does it work?
I'm not the best explainer) super simple scheme:
Component
loads some resource and throws a promiseErrorBoundary
catch this promise and wait until it resolves and continue render
Where does that promise come from?
Components throw them:
- https://github.com/vercel/swr/blob/master/src/use-swr.ts#L801
- https://github.com/mbrevda/react-image/blob/master/src/useImage.tsx#L80
- https://github.com/jaredpalmer/the-platform/blob/master/src/Img.tsx
iframe component?
Iframe component is not so trivial for suspense, but can be implemented with hacks:
https://gist.github.com/threepointone/e73a87f7bbbebc78cf71744469ec5a15
Suspense is still experimental, but react community have a lot components that supports this feature
So i think it fit great for remotion
from remotion.
Related Issues (20)
- Error message "react/jsx-runtime" when making a react component in library authoring template. HOT 1
- Editor guides context does break asset view
- Getting a different shade of green when rendering to a video HOT 1
- MaxListenersExceededWarning
- remotion/google-fonts: Expose loadFont promise HOT 4
- Getting wrong stacktrace line number in some cases HOT 1
- Allow a `<Sequence>` to have a `width` and `height`
- Ability to properly handle bad videos in OffthreadVideo without crashing
- registerRoot() was called more than once because of hot reloading in preview mode HOT 1
- Highlight Selected Composition in Compositions Panel when Found via Quick Switcher HOT 5
- Feature Request - Render Still using python SDK HOT 10
- Beep when a render is finished HOT 23
- TransitionSeries is not working - Internals.addSequenceStackTraces is not a function HOT 4
- Issue with missing export from "@remotion/transitions" module when deploying Player using Vite. HOT 1
- Module parse failed: Unexpected character '�' (1:0) in @remotion/compositor-darwin-arm64/compositor HOT 1
- [Question] - AWS Lambda concurrency limit configuration HOT 2
- Which breaking changes should be made for Remotion v5? HOT 8
- Creating temporary chunks for long videos and concat them later HOT 1
- Transitions make the elements unselectable by covering it HOT 3
- `deleteRender` is not available in `@remotion/lambda/client` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remotion.