Skip to content

[camera_web] Re: Support for camera stream on web - #7950

Open
TecHaxter wants to merge 93 commits into
flutter:mainfrom
TecHaxter:camera_web_stream
Open

[camera_web] Re: Support for camera stream on web#7950
TecHaxter wants to merge 93 commits into
flutter:mainfrom
TecHaxter:camera_web_stream

Conversation

@TecHaxter

Copy link
Copy Markdown

This PR aims to provide support for strartImageStream and stopImageStream on Web.

#92460

Based on #6944 from the archived plugins repository

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

POV: my first PR on a public repo
Contains required commits from the PR #6443, resolves unnecessary 202 commits

@github-actions github-actions Bot removed the CICD Run CI/CD label May 17, 2026
@TecHaxter

Copy link
Copy Markdown
Author

Thanks for the valuable comments Ditman and the suggestion about MediaStreamTrackProcessor :)
I have drafted some changes locally to use that method as primary streaming option, and requestAnimationCallback as a fallback.
Please be patient for next couple of commits from my side very soon. Thanks again for your patience. 🙏

@kevmoo

kevmoo commented May 18, 2026

Copy link
Copy Markdown
Contributor

@TecHaxter – we love thoughtful, polite contributors. Thanks for helping out!

@jiechic

jiechic commented Jun 30, 2026

Copy link
Copy Markdown

is any update on this PR?

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

From triage: @mdebbar it looks from discussion above like this is ready for a hopefully final review round.

@scognito

This comment was marked as off-topic.

cameraId: cameraId,
);
if (videoFrame.visibleRect == null) {
throw CameraWebException(

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.

Let's call videoFrame.close() before throwing to avoid a memory leak.

..objectFit = 'cover';
}

StreamController<CameraImageData>? _cameraFrameStreamController;

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.

Should this controller be closed in the dispose() method?

..width = width
..height = height;
}
final web.CanvasRenderingContext2D context = _canvasElement!.context2D;

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.

Is there a reason we aren't using 'willReadFrequently': true for this context?

_isCameraFrameStreamInitialized() && _cameraFrameStreamController!.hasListener;

/// Used for safely emitting camera frame stream event
void _safelyEmitCamereFrameStreamEvent(CameraImageData data) {

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.

typo:

Suggested change
void _safelyEmitCamereFrameStreamEvent(CameraImageData data) {
void _safelyEmitCameraFrameStreamEvent(CameraImageData data) {

}

/// Used for safely closing camera frame stream event
void _safelyCloseCamereFrameStream() {

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.

typo:

Suggested change
void _safelyCloseCamereFrameStream() {
void _safelyCloseCameraFrameStream() {

}

/// Used for safely emitting camera frame stream error
void _safelyEmitCamereFrameStreamError(Object error) {

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.

typo:

Suggested change
void _safelyEmitCamereFrameStreamError(Object error) {
void _safelyEmitCameraFrameStreamError(Object error) {

bool Function(JSAny) checkType, {
int cameraId = 0,
}) {
// Use the callback to perform the compile-time bound check

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.

Did you mean runtime instead of "compile-time"?

@mdebbar mdebbar added the CICD Run CI/CD label Aug 11, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 11, 2026
@mdebbar mdebbar added the CICD Run CI/CD label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: camera platform-web triage-web Should be looked at in web triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants