Selecting a file to upload causes mobile Safari to crash

假如想象 提交于 2019-12-20 09:11:46

问题


I've been experiencing behaviour on, at least my iPhone 6 Plus, when using the <input type="file"> to let the user upload an image.

<div class="add__from-camera">
    <button class="add__from-camera__btn">
        <i class="fa fa-fw fa-camera"></i> Add with Camera
    </button>
    <input class="add__from-camera__input" type="file">
</div>

This rest case results in crashes of the tab about 50% of the time, and in my app about 90% of the time.

I was 'lucky' enough to get all of Safari to crash once when the error happened, and this was part of the log:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00030000006467ba
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   WebKit                          0x000000018a48566c WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon(WTF::Vector<WTF::String, 0ul, WTF::CrashOnOverflow> const&, WTF::String const&, API::Data const*) + 44
1   WebKit                          0x000000018a461648 WebKit::WebOpenPanelResultListenerProxy::chooseFiles(API::Array*, API::String*, API::Data const*) + 100
2   WebKit                          0x000000018a461648 WebKit::WebOpenPanelResultListenerProxy::chooseFiles(API::Array*, API::String*, API::Data const*) + 100
3   WebKit                          0x000000018a413020 -[WKFileUploadPanel _chooseFiles:displayString:iconImage:] + 468

It seems to indicate an (overflow?) error in display the little thumbnail preview? Is there a way to prevent Safari from crashing when using file input, or at least don't render the thumbnail preview?


回答1:


Try this:

<input class="add__from-camera__input" type="file" accept="image/*;capture=camera">


来源:https://stackoverflow.com/questions/26955216/selecting-a-file-to-upload-causes-mobile-safari-to-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!