Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile Photo Preview in Account Details displaying broken image #464

Closed
cnorm35 opened this issue Aug 23, 2023 · 11 comments
Closed

Profile Photo Preview in Account Details displaying broken image #464

cnorm35 opened this issue Aug 23, 2023 · 11 comments

Comments

@cnorm35
Copy link
Contributor

cnorm35 commented Aug 23, 2023

Steps to Reproduce

With a new account, uploading a profile photo from the Account Details section displays a broken image

Additional Details

The image (png) is uploaded and is displaying the correct image in the Account Avatar within the top menu.

I saw this in the Rails logs and have ran into this issue before and believe it's related to vips image processing

web              |   Disk Storage (0.2ms) Downloaded file from key: vphget8zh1qi8wip2txs7jq7qahl
web              | objc[65257]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
web              | objc[65257]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
web              | [64483] - Worker 1 (PID: 65263) booted in 0.0s, phase: 0

Commenting out # workers ENV.fetch("WEB_CONCURRENCY", 4) from config/puma.rb and restarting the rails server resolves this issue.

Screenshots

Displaying broken Image
Screenshot 2023-08-23 at 11 51 43 AM

Displaying correct image after updating Puma config
Screenshot 2023-08-23 at 11 52 25 AM

@jagthedrummer
Copy link
Contributor

I just looked into this and the fix of disabling puma workers didn't do anything for me. After poking around I think we're just not trying to render an image.

@gazayas, it looks like the not rendering an image is related to the recent addition of adding ActiveStorage as an upload option.

<% if cloudinary_enabled? %>
<%= render 'shared/fields/cloudinary_image', method: :profile_photo_id %>
<% else %>
<%= render 'shared/fields/file_field', method: :profile_photo %>
<% end %>

I'll open an issue about that and link it here.

@jagthedrummer
Copy link
Contributor

#498

@cnorm35
Copy link
Contributor Author

cnorm35 commented Aug 31, 2023

@jagthedrummer Thanks for looking into that! That issue may have just been something I was running into locally. I've seen the

objc[65257]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug

error before on another project and believe it was related to vips image processing on OSX and running specs parallel.

Let me know if you'd like me to close this issue.

@jagthedrummer
Copy link
Contributor

@cnorm35, let's leave it open for now. I'd like to get to where we at least attempt to display an image that we're processing locally and then see if we can recreate this.

@jagthedrummer
Copy link
Contributor

After getting to where we try to render an image (WIP PR #515) I was able to recreate this issue:

15:06:28 web.1              | Processing by ActiveStorage::Representations::RedirectController#show as PNG
15:06:28 web.1              |   Parameters: {"signed_blob_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--f19f613de72e1c4e2b0a23fd1f8bcdf93fd23519", "variation_key"=>"[FILTERED]", "filename"=>"Do you want avocados or not"}
15:06:28 web.1              |   ActiveStorage::Blob Load (0.8ms)  SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2  [["id", 3], ["LIMIT", 1]]
15:06:28 web.1              |   ActiveStorage::VariantRecord Load (1.1ms)  SELECT "active_storage_variant_records".* FROM "active_storage_variant_records" WHERE "active_storage_variant_records"."blob_id" = $1 AND "active_storage_variant_records"."variation_digest" = $2 LIMIT $3  [["blob_id", 3], ["variation_digest", "uyx6Kcit1Aa78Mrn7bVgZ7OZn0Y="], ["LIMIT", 1]]
15:06:28 web.1              |   Disk Storage (0.4ms) Downloaded file from key: zwm14lvqm1m0q6n0f5zsauww4ur5
15:06:28 web.1              | objc[18525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
15:06:28 web.1              | objc[18525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
15:06:28 web.1              | [17939] - Worker 1 (PID: 18531) booted in 0.0s, phase: 0

CleanShot 2023-09-01 at 15 07 55

Commenting out this line, or setting the value to 0 gets it to work.

https://github.com/bullet-train-co/bullet_train/blob/122f6953f9eb5df3d670923cda38511a45d4772a/config/puma.rb#L33

@cnorm35
Copy link
Contributor Author

cnorm35 commented Sep 1, 2023

Not sure if it's helpful, but I've seen those same warning pop up in system tests that were logging that error, passing OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES seems to resolve it

@jagthedrummer
Copy link
Contributor

jagthedrummer commented Sep 1, 2023

@cnorm35 after poking around a bit I found a way to solve this without disabling puma workers.

libvips/ruby-vips#155 (comment)

Adding gem "ruby-vips" in the :development group of the Gemfile did the trick for me.

I'll whip up a PR for that real quick.

jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this issue Sep 1, 2023
This (mostly) fixes the problem reported in bullet-train-co/bullet_train-core#464

However, due to bullet-train-co/bullet_train-core#498 we don't currently try to show
a user profile photo if we're using ActiveStorage instead of Cloudinary.

Here's some context about why we need to add this directly to the
`Gemfile`.
libvips/ruby-vips#155 (comment)
@jagthedrummer
Copy link
Contributor

jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this issue Sep 1, 2023
* Add `ruby-vips` in the `:development, :test` group

This (mostly) fixes the problem reported in bullet-train-co/bullet_train-core#464

However, due to bullet-train-co/bullet_train-core#498 we don't currently try to show
a user profile photo if we're using ActiveStorage instead of Cloudinary.

Here's some context about why we need to add this directly to the
`Gemfile`.
libvips/ruby-vips#155 (comment)

* Try it here
@cnorm35
Copy link
Contributor Author

cnorm35 commented Sep 1, 2023

Awesome, thanks so much for the update!

@jagthedrummer
Copy link
Contributor

I'm going to leave this open until we have a fix for #498, just so we can be really really sure we got it.

@jagthedrummer
Copy link
Contributor

OK, this should be fixed with the merge of #515. I'll be cutting a new release for version 1.4.5 shortly.

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

No branches or pull requests

2 participants