Commit Graph

20 Commits (5ebc1af91e96ca065ea55f20e94de5d874a442c8)

Author SHA1 Message Date
Shlee 79af98f9d0
Merge pull request #6667 from vinzgreg/fix/blurhash-memory-strands-video-uploads
Fix videos never reaching cloud storage by downscaling in Blurhash (#2652)
4 weeks ago
Shlee 186fa7c860
Update VideoThumbnail.php 4 weeks ago
Your Name c0cde2f682 refactor: move 52 legacy models from App\ to App\Models\
Move all Eloquent models from the app/ root directory to app/Models/
for consistency with modern Laravel conventions. The project already had
54 models in App\Models; this migrates the remaining 52 legacy models.

Changes:
- Move 52 model files from app/ to app/Models/
- Update namespace declarations in each model
- Update all ~1000 import references across the codebase
- Add Relation::morphMap() in AppServiceProvider for backward
  compatibility with existing polymorphic database records
- Add missing HasSnowflakePrimary imports for models that relied
  on same-namespace resolution
4 weeks ago
Your Name c807a8524c refactor: replace short facade aliases with fully-qualified imports
Convert all 273 short facade alias imports (e.g. 'use Cache;') to their
fully-qualified class names (e.g. 'use Illuminate\Support\Facades\Cache;')
across 193 files.

This resolves 643 PHPStan 'class.notFound' errors caused by the static
analyzer being unable to resolve global aliases, and aligns with modern
Laravel conventions. It also unblocks removing the aliases array from
config/app.php in a future change.

All 107 tests pass.
1 month ago
vinz ef56880a74 Fix videos never reaching cloud storage by downscaling in Blurhash
Blurhash::generate() allocates one PHP array per pixel of the source. At
roughly 255 bytes per pixel (measured: 224 MB peak for a 720x1280 frame) a
1920x1080 frame approaches half a gigabyte.

Image thumbnails survive this because they are capped at 640x640 in
Image::__construct() *and* run under that constructor's
ini_set('memory_limit', '1024M'). Video thumbnails get neither: FFmpeg saves
them at the source video's resolution, and VideoThumbnail never raises the
limit. So a video whose frame is 1080p or larger exhausts memory_limit.

That is a PHP fatal, not an \Exception, which has three consequences:

  - the catch block in VideoThumbnail::handle() does not catch it
  - the job never lands in failed_jobs, so nothing reports a problem
  - MediaStoragePipeline::dispatch() on the last line of handle() never runs

The video therefore stays on local disk permanently while images beside it
replicate normally. Reported in #2652 (2021-02-13) and diagnosed correctly in
that thread on 2021-11-04.

Two changes:

1. Blurhash::generate() downscales to 128px on the long edge before sampling.
   The result is a 4x4-component DCT, so full-resolution sampling adds
   essentially nothing: measured against the full-resolution hash, mean
   per-channel deviation of the decoded 24x24 preview is ~7.5/255 at a 32px
   sample, ~4.5/255 at 64px, ~2.5/255 at 128px, and no better at 256px. Peak
   memory for the frame above drops from 224 MB to 6 MB.

   This removes the ceiling for every caller rather than moving it, which is
   all that raising memory_limit would have done. Existing stored hashes are
   not recomputed, so nothing already published changes appearance.

2. VideoThumbnail wraps the blurhash in its own try/catch, so a decorative
   step can no longer skip the replication dispatch. Change 1 covers the
   fatal; this covers any ordinary exception.

Verified on a live instance with S3 cloud storage: a 1920x1080 video that
previously stranded now generates a blurhash, uploads original and thumbnail
to the bucket, sets cdn_url/thumbnail_url/replicated_at, and removes the local
copies. Existing images re-hash to visually identical previews.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 months ago
Your Name 13d877b832 bug 8 months ago
Daniel Supernault 53742fa699
Lint 9 months ago
Your Name ca6c875bbb Fix PHPStan class.notFound issues 11 months ago
Daniel Supernault f0ba2dfc69
Update VideoThumbnail job, dispatch HLS job when applicable 3 years ago
Daniel Supernault 47571887fe
Improve cache invalidation after processing VideoThumbnail to eliminate "No Preview Available" on grid feeds 4 years ago
Daniel Supernault 896452c74c
Update VideoThumbnail job, generate blurhash for videos 6 years ago
Daniel Supernault 98c44f7bdb
Update VideoThumbnail, add MediaStoragePipeline 6 years ago
Daniel Supernault 2284d85f9c
Update VideoThumbnail job, remove outdated cloud storage logic 6 years ago
Daniel Supernault 6bb8099583
Update VideoThumbnail pipeline job 7 years ago
Daniel Supernault e14e18e6b4
Update VideoThumbnail pipeline 7 years ago
Daniel Supernault 44ba4749f9
Update VideoThumbnail 7 years ago
Daniel Supernault a1c29b50e3
Update VideoPipeline 7 years ago
Daniel Supernault 6b7caa988f
Update VideoThumbnail job 8 years ago
Daniel Supernault c4b1f18755
Update VideoThumbnail job 8 years ago
Daniel Supernault 7c85a6178c
Add Video jobs 8 years ago