Failed to execute 'texImage2D' on 'WebGL2RenderingContext': The image element contains cross-origin data, and may not be loaded. #217.
Skiptocontent
{{message}}
ml5js
/
ml5-library
Public
Notifications
Fork
815
Star
5.8k
Code
Issues
213
Pullrequests
57
Actions
Projects
11
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Actions
Projects
Wiki
Security
Insights
Newissue
Haveaquestionaboutthisproject?SignupforafreeGitHubaccounttoopenanissueandcontactitsmaintainersandthecommunity.
Pickausername
EmailAddress
Password
SignupforGitHub
Byclicking“SignupforGitHub”,youagreetoourtermsofserviceand
privacystatement.We’lloccasionallysendyouaccountrelatedemails.
AlreadyonGitHub?
Signin
toyouraccount
Jumptobottom
Failedtoexecute'texImage2D'on'WebGL2RenderingContext':Theimageelementcontainscross-origindata,andmaynotbeloaded.
#217
Closed
iduartopenedthisissue
Sep21,2018
·16comments
Closed
Failedtoexecute'texImage2D'on'WebGL2RenderingContext':Theimageelementcontainscross-origindata,andmaynotbeloaded.
#217
iduartopenedthisissue
Sep21,2018
·16comments
Comments
Copylink
iduart
commented
Sep21,2018
Inmyexamplehttps://ideanb.github.io/best-guess/
Icanclassifyimagesinthesameserversuchas
images/dexter1.jpg
images/dexter2.jpg
images/dee2.jpg
images/dee4.jpg
But,IfItrytoclassifyanexternallink,let'ssayhttps://images-na.ssl-images-amazon.com/images/I/41Xe%2B6VIgtL.jpg
Itthrowsthiserror
gpgpu_util.js:153Uncaught(inpromise)DOMException:Failedtoexecute'texImage2D'on'WebGL2RenderingContext':Theimageelementcontainscross-origindata,andmaynotbeloaded.
athttps://unpkg.com/[email protected]/dist/ml5.min.js:1:170216
atse(https://unpkg.com/[email protected]/dist/ml5.min.js:1:160367)
atet(https://unpkg.com/[email protected]/dist/ml5.min.js:1:170191)
ate.uploadPixelDataToTexture(https://unpkg.com/[email protected]/dist/ml5.min.js:1:177628)
ate.fromPixels(https://unpkg.com/[email protected]/dist/ml5.min.js:1:212633)
ate.fromPixels(https://unpkg.com/[email protected]/dist/ml5.min.js:1:673668)
ate.fromPixels(https://unpkg.com/[email protected]/dist/ml5.min.js:1:113965)
athttps://unpkg.com/[email protected]/dist/ml5.min.js:1:81527
ate.tidy(https://unpkg.com/[email protected]/dist/ml5.min.js:1:609188)
atObject.n.value(https://unpkg.com/[email protected]/dist/ml5.min.js:1:81504)
AnyIdeasonhowtomakeitacceptexternallinks?
Thetextwasupdatedsuccessfully,buttheseerrorswereencountered:
Allreactions
Copylink
Member
cvalenzuela
commented
Sep24,2018
Youshouldsetthecrossoriginattributeinthehtmltag:
Seehttps://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes
👍
27
ymjongbin,peacefulseeker,markoczy,jdnichollsc,maxxporoshin,anisharya16,ungureanuliviu,spidgorny,Yousabry,Chazie9,and17morereactedwiththumbsupemoji
🎉
4
Chazie9,fridge1234,JelaniThompson,andclearlyTHUYDOANreactedwithhoorayemoji
❤️
12
biranchi2018,shlajin,jsuryahyd,geek-ibrar,santosh898,wlwl2,jdnichollsc,Chazie9,Aweller95,fridge1234,and2morereactedwithheartemoji
🚀
4
fridge1234,JelaniThompson,H4T3H4K3RS,andclearlyTHUYDOANreactedwithrocketemoji
👀
3
fridge1234,JelaniThompson,andclearlyTHUYDOANreactedwitheyesemoji
Allreactions
👍
27reactions
🎉
4reactions
❤️
12reactions
🚀
4reactions
👀
3reactions
Sorry,somethingwentwrong.
Copylink
Author
iduart
commented
Sep24,2018
@cvalenzuelaThanksforyourresponse
IwasalreadyusingcrossOrigin="anonymous"inmyexample.
IwasabletofixthisissuebysettingcrossOriginbeforesrcattribute.
constimg=newImage();
img.crossOrigin="anonymous";
img.src=url;
img.width=224;
img.height=224;
👍
44
okramovic,rakannimer,jrg94,Gowtham171996,Makio64,GantMan,ZhaoChuyang,adrienZ,shubham1310,geremora,and34morereactedwiththumbsupemoji
🎉
10
olchyk98,adrienZ,Lothav,peacefulseeker,paullacour,hsxyhao,pandabamboo90,duhaime,Chazie9,andjonathanzunigareactedwithhoorayemoji
Allreactions
👍
44reactions
🎉
10reactions
Sorry,somethingwentwrong.
Copylink
Member
cvalenzuela
commented
Sep24,2018
great!
Allreactions
Sorry,somethingwentwrong.
cvalenzuela
closedthisascompleted
Sep24,2018
Copylink
Member
shiffman
commented
Oct29,2018
I'mnotsureifitmakessensetore-openthisorfileanewissue,butitlookslikethisproblemismoresignificantduetoissuesitcauseswiththep5webeditor(whichhostsimageuploadsviaanS3bucket).@catarakandIwerejustdiscussingthisinane-mailthread.
I’mactuallyabletoreproducethisbugoutsideofthewebeditor,locallyonmycomputer,usingjustp5.jsandml5.js.TheS3bucketalsowhitelistslocalhost:8000forCORS,soifservetheexamplelocallyfromlocalhost:8000,andItrytoloadanimagefromtheS3bucket,e.g.https://assets.editor.p5js.org/57c1b671a44b7d771d5c6d2c/0b4ac100-6a05-40d2-a378-2baa137710c2.jpg
ForthetimebeingIcreatedanexamplethatshowsimageclassificationwithdraganddroptoavoidthisissue:
https://editor.p5js.org/ml5/sketches/S1PLinE27
Allreactions
Sorry,somethingwentwrong.
shiffman
reopenedthis
Oct29,2018
Copylink
catarak
commented
Oct29,2018
Theworkaroundwe'vefoundtogetthistoworkwithp5.jsistodothefollowing:
letclassifier=ml5.imageClassifier('MobileNet',modelReadyCallback);
letimg=createImg('different_origin_but_CORS_enabled.jpg');
img.elt.crossOrigin="Anonymous";
classifier.predict(img,gotResults);
isthisjustinevitablewithhowWebGLoperateswithrespecttoCORS?Iguessit'sjustweirdtomethateveniftheimageisbeingservedwithCORSenabled,andtheoriginiswhitelisted,thiserrorstillcomesup.
Allreactions
Sorry,somethingwentwrong.
Copylink
Member
shiffman
commented
Oct30,2018
WouldsupportingloadImage()asdiscussed#92(comment)helpwiththeCORSstuff?
Allreactions
Sorry,somethingwentwrong.
Copylink
catarak
commented
Oct30,2018
Howdoyouuseap5imgwithml5?Doyouwriteittothecanvas,andtheninputthecanvastotheclassifier?Icouldn'tfigureouthowtogetthatworking.
Allreactions
Sorry,somethingwentwrong.
Copylink
Member
shiffman
commented
Oct30,2018
Ibelievesupportwasaddedvia#206from@meiamsome,butIamhavingtroublegettingloadImage()plusml5.ImageClassifier()towork,continuingtotest...
👍
2
okramovicandTheDeterminatorreactedwiththumbsupemoji
Allreactions
👍
2reactions
Sorry,somethingwentwrong.
jrg94
mentionedthisissue
Nov15,2018
ConverttoGitHubPages
jrg94/CSE5542#19
Closed
Copylink
addys888
commented
Jan10,2019
IfyoutrieditoverlightningcomponentthenpleasedegradeyourComponentAPIversionwith39orless.
Allreactions
Sorry,somethingwentwrong.
Copylink
Member
shiffman
commented
Feb14,2019
AnupdateI'mgettingloadImage()toworknow.AndIcanalsorunclassificationoncanvas!I'mnotsurewhyIdidn'tgetthistoworkbeforebuthereisademonstration!Veryexciting!
https://editor.p5js.org/ml5/sketches/EB4LMfd1h
🚀
2
shlomi-lachmishandcatarakreactedwithrocketemoji
Allreactions
🚀
2reactions
Sorry,somethingwentwrong.
yining1023
mentionedthisissue
Feb18,2019
feat(KNNClassifier):AddloadData()thatenablesusertoloaddat…
#279
Merged
ghost
mentionedthisissue
Jul4,2019
Fixtexturesnotdisplaying
sksharan/era-engine#2
Merged
Copylink
eliamjuda
commented
Sep15,2019
ajajjyaentendijajaok
😕
1
omzetonreactedwithconfusedemoji
👀
1
avalanche1reactedwitheyesemoji
Allreactions
😕
1reaction
👀
1reaction
Sorry,somethingwentwrong.
Copylink
hiteshsahu
commented
Oct9,2019
•
edited
IfusingReactusecrossOrigininsteadofcrossorigin
{
this.image=image;
}}
src="./assets/bird.jpeg"
id="image"
width="400"
/>
👍
1
Alkaluropsreactedwiththumbsupemoji
Allreactions
👍
1reaction
Sorry,somethingwentwrong.
Copylink
AliouneY
commented
Dec29,2019
I'mconfusedastowhytheerrorclaimsthatmyelementcontainscross-origindatawhenIloadeditfromalocalsource...cananyoneexplainwhythatmightbe?
Allreactions
Sorry,somethingwentwrong.
PullJosh
mentionedthisissue
Jan6,2020
Bestwaytohandleloadingprojectassets?
leopard-js/leopard#38
Closed
Copylink
Contributor
joeyklee
commented
Feb19,2020
•
edited
HiAll.Itseemsthishasbeenresolved.Iwillclosethisfornow.Feelfreetoreopenifitisstillrelevant.Thanksforyourparticipation!
Allreactions
Sorry,somethingwentwrong.
joeyklee
closedthisascompleted
Feb19,2020
melMass
mentionedthisissue
Sep1,2020
AddDemolink
john--kane/svelteml#2
Open
Copylink
rahuldess
commented
Nov8,2020
I'mconfusedastowhytheerrorclaimsthatmyelementcontainscross-origindatawhenIloadeditfromalocalsource...cananyoneexplainwhythatmightbe?
EvenIhavethesamequestion
Allreactions
Sorry,somethingwentwrong.
Copylink
haoruilee
commented
Nov25,2020
Ihavethesamequestion.
Allreactions
Sorry,somethingwentwrong.
Signupforfree
tojointhisconversationonGitHub.
Alreadyhaveanaccount?
Signintocomment
Assignees
Nooneassigned
Labels
Noneyet
Projects
Noneyet
Milestone
Nomilestone
Development
Nobranchesorpullrequests
11participants
Youcan’tperformthatactionatthistime.
Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession.
Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.